Package com.belerweb.social.exception

Examples of com.belerweb.social.exception.SocialException


    HttpGet request = new HttpGet("http://ptlogin2.qq.com/login?" + StringUtils.join(params, "&"));
    request.addHeader(new BasicHeader("Referer", loginUi));
    request.addHeader(new BasicHeader("Accept-Language", "zh-cn,zh"));
    HttpResponse response = http.execute(request);
    if (!Http.isRequestSuccess(response)) {
      throw new SocialException("Step 6, login failed.");
    }

    String html = Http.responseToString(response);
    if (!html.contains("登录成功")) {
      throw new SocialException("Step 7, login failed.");
    }

    for (Header header : response.getHeaders("Set-Cookie")) {
      Matcher matcher = Pattern.compile("skey=([^;]+);").matcher(header.getValue());
      if (matcher.find()) {
        skey = matcher.group(1);
        session = true;
      }
    }
    if (!session) {
      throw new SocialException("Step 8, get skey failed.");
    }
  }
View Full Code Here


      request.addHeader(new BasicHeader("Referer",
          "http://ctc.qzs.qq.com/qzone/v8/pages/visitors/refuse.html"));
      request.addHeader(new BasicHeader("Accept-Language", "zh-cn,zh"));
      HttpResponse response = http.execute(request);
      if (!Http.isRequestSuccess(response)) {
        throw new SocialException("Step 9, get visitor simple failed.");
      }
      String html = Http.responseToString(response);
      JSONObject json =
          new JSONObject(html.substring(html.indexOf("{"), html.lastIndexOf("}") + 1));
      if (json.getInt("code") != 0) {
        session = false;
        http = Http.newClient();
        loginUi = null;
        loginSig = null;
        skey = null;
        return getSimple();
      }

      return json;
    } catch (ClientProtocolException e) {
      throw new SocialException(e);
    } catch (IOException e) {
      throw new SocialException(e);
    } catch (HttpException e) {
      throw new SocialException(e);
    } catch (DecoderException e) {
      throw new SocialException(e);
    }
  }
View Full Code Here

TOP

Related Classes of com.belerweb.social.exception.SocialException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.