Package com.belerweb.social.exception

Examples of com.belerweb.social.exception.SocialException


        return new Result<T>(parse(new JSONArray(json), resultType));
      } else {
        return parse(new JSONObject(json), resultType);
      }
    } catch (Exception e) {
      throw new SocialException(e);
    }
  }
View Full Code Here


        T obj = (T) parse.invoke(null, jsonObject);
        return new Result<T>(obj);
      }
      return new Result<T>(error);
    } catch (Exception e) {
      throw new SocialException(e);
    }
  }
View Full Code Here

          list.add((T) parse.invoke(null, jsonArray.getJSONObject(i)));
        }
      }
      return list;
    } catch (Exception e) {
      throw new SocialException(e);
    }
  }
View Full Code Here

    } else if (obj instanceof String) {
      try {
        SimpleDateFormat format = new SimpleDateFormat(pattern, locale);
        result = format.parse((String) obj);
      } catch (ParseException e) {
        throw new SocialException(e);
      }
    }

    return result;
  }
View Full Code Here

  public boolean test() throws SocialException {
    try {
      return login();
    } catch (SocketException e) {
      e.printStackTrace();
      throw new SocialException(e);
    } catch (IOException e) {
      e.printStackTrace();
      throw new SocialException(e);
    } finally {
      try {
        this.client.disconnect();
      } catch (IOException e) {
        e.printStackTrace();
View Full Code Here

  /**
   * 下载所有电子邮件到指定目录
   */
  public void download(File dir) throws SocialException {
    if (!dir.isDirectory() || !dir.canWrite()) {
      throw new SocialException("The specified directory is unavailable.");
    }

    try {
      if (login()) {
        POP3MessageInfo[] messages = client.listUniqueIdentifiers();
        if (messages == null) {
          LOGGER.debug("Could not retrieve message list.");
          throw new SocialException("Could not retrieve message list.");

        } else {
          for (POP3MessageInfo message : messages) {
            File eml = new File(dir, username + "@" + host + "/" + message.identifier + ".eml");
            try {
View Full Code Here

      String json =
          weixin.post("https://api.weixin.qq.com/cgi-bin/menu/create?access_token=" + accessToken,
              new StringEntity(request.toString()));
      return Result.parse(json, Error.class);
    } catch (UnsupportedEncodingException e) {
      throw new SocialException(e);
    }
  }
View Full Code Here

      String json =
          post("https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=" + accessToken,
              new StringEntity(request.toString()));
      return Result.parse(json, QRTicket.class);
    } catch (UnsupportedEncodingException e) {
      throw new SocialException(e);
    }
  }
View Full Code Here

      String json =
          post("https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=" + accessToken,
              new StringEntity(message.toJSON()));
      return new Result<Boolean>(Error.parse(new JSONObject(json)));
    } catch (UnsupportedEncodingException e) {
      throw new SocialException(e);
    }
  }
View Full Code Here

  private void openLogin() throws ClientProtocolException, IOException, HttpException {
    String uri = "http://user.qzone.qq.com/" + qq + "/friendvisitor";
    HttpResponse response = http.execute(new HttpGet(uri));
    if (!Http.isRequestSuccess(response)) {
      throw new SocialException("Step 1, open login ui failed.");
    }

    Document doc = Jsoup.parse(Http.responseToString(response));
    loginUi = doc.select("#login_frame").get(0).attr("src");
    HttpGet request = new HttpGet(loginUi);
    request.addHeader(new BasicHeader("Referer", uri));
    response = http.execute(request);
    if (!Http.isRequestSuccess(response)) {
      throw new SocialException("Step 2, open login ui failed.");
    }

    doc = Jsoup.parse(Http.responseToString(response));
    Matcher matcher =
        Pattern.compile("login_sig\\s*:\\s*[\"']([^\"']+)[\"']").matcher(
            doc.select("script").get(0).html());
    if (!matcher.find()) {
      throw new SocialException("Step 3, login page isn't contain login_sig.");
    }
    loginSig = matcher.group(1);
  }
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.