Exemplo n.º 1
0
 private boolean pingHost(String hostName) {
   HttpResult result =
       HttpClientHelper.get(
           hostName,
           new Header[] {new BasicHeader(ConstantUtil.VER, ConfigUtil.getValue(ConfigUtil.VER))});
   if (result != null && result.getStatuCode() == 200) {
     return true;
   }
   return false;
 }
Exemplo n.º 2
0
 /**
  * 检测账号是否需要验证码
  *
  * @param context
  * @param user
  * @return 0,不需要 1,需要
  */
 public static int checkVerify(Context context, String user) {
   HttpResult verResult =
       HttpClientHelper.get(
           VER_CODE_URL,
           null,
           new NameValuePair[] {
             new BasicNameValuePair("u", user),
             new BasicNameValuePair("cachetime", String.valueOf(System.currentTimeMillis()))
           });
   Cookie verCodeCookie = verResult.getCookie(CHECK_RESULT);
   String checkResult = verCodeCookie.getValue();
   System.out.println("CHECK_RESULT:" + checkResult);
   saveDefaultVerify(context, checkResult.substring(checkResult.indexOf(":") + 1));
   if (checkResult.charAt(0) == '0') {
     String VERIFY_KEY = verResult.getCookie("VERIFY_KEY").getValue();
     saveUserKey(context, VERIFY_KEY);
     return 0;
   }
   return 1;
 }
Exemplo n.º 3
0
 public static Bitmap getVerify(Context context) {
   String url = "http://verify.xunlei.com/image?cachetime=" + System.currentTimeMillis();
   System.out.println("获取验证码===>>>" + url);
   HttpResult result = HttpClientHelper.get(url);
   byte[] data = null;
   if (result != null && result.getStatuCode() == HttpStatus.SC_OK) {
     Cookie cookie = result.getCookie("VERIFY_KEY");
     data = result.getResponse();
     if (cookie == null) {
       return null;
     }
     String value = cookie.getValue();
     System.out.println(value);
     saveUserKey(context, value);
   }
   Bitmap bm = null;
   if (data != null) {
     ByteArrayInputStream is = new ByteArrayInputStream(data);
     bm = BitmapFactory.decodeStream(is);
   }
   return bm;
 }