示例#1
1
  public UserListBean getUserList() throws WeiboException {

    String url = WeiBoURLs.USERS_SEARCH;

    Map<String, String> map = new HashMap<String, String>();
    map.put("access_token", access_token);
    map.put("count", count);
    map.put("page", page);
    map.put("q", q);

    String jsonData = null;

    jsonData = HttpUtility.getInstance().executeNormalTask(HttpMethod.Get, url, map);

    Gson gson = new Gson();

    UserListBean value = null;
    try {
      value = gson.fromJson(jsonData, UserListBean.class);
    } catch (JsonSyntaxException e) {

      AppLoggerUtils.e(e.getMessage());
    }

    return value;
  }
示例#2
0
  public List<String> getInfo() throws WeiboException {

    String url = WeiBoURLs.GROUP_MEMBER_LIST;

    Map<String, String> map = new HashMap<String, String>();
    map.put("access_token", access_token);
    map.put("uids", uids);

    String jsonData = HttpUtility.getInstance().executeNormalTask(HttpMethod.Get, url, map);

    Gson gson = new Gson();

    List<GroupUser> value = null;
    try {
      value = gson.fromJson(jsonData, new TypeToken<List<GroupUser>>() {}.getType());
    } catch (JsonSyntaxException e) {
      AppLoggerUtils.e(e.getMessage());
    }

    if (value != null && value.size() > 0) {
      GroupUser user = value.get(0);
      List<String> ids = new ArrayList<String>();
      for (GroupBean b : user.lists) {
        ids.add(b.getIdstr());
      }
      return ids;
    }

    return null;
  }
示例#3
0
  private String handleError(HttpURLConnection urlConnection) throws WeiboException {

    String result = readError(urlConnection);
    String err = null;
    int errCode = 0;
    try {
      AppLoggerUtils.e("error=" + result);
      JSONObject json = new JSONObject(result);
      err = json.optString("error_description", "");
      if (TextUtils.isEmpty(err)) {
        err = json.getString("error");
      }
      errCode = json.getInt("error_code");
      WeiboException exception = new WeiboException();
      exception.setError_code(errCode);
      exception.setOriError(err);

      if (errCode == ErrorCode.EXPIRED_TOKEN || errCode == ErrorCode.INVALID_TOKEN) {
        Utility.showExpiredTokenDialogOrNotification();
      }

      throw exception;

    } catch (JSONException e) {
      e.printStackTrace();
    }

    return result;
  }
示例#4
0
  public SearchStatusListBean getStatusList() throws WeiboException {

    String url = WeiBoURLs.STATUSES_SEARCH;

    Map<String, String> map = new HashMap<String, String>();
    map.put("access_token", access_token);
    map.put("count", count);
    map.put("page", page);
    map.put("q", q);

    String jsonData = null;

    jsonData = HttpUtility.getInstance().executeNormalTask(HttpMethod.Get, url, map);

    Gson gson = new Gson();

    SearchStatusListBean value = null;
    try {
      value = gson.fromJson(jsonData, SearchStatusListBean.class);
      List<MessageBean> list = value.getItemList();

      Iterator<MessageBean> iterator = list.iterator();
      while (iterator.hasNext()) {
        MessageBean msg = iterator.next();
        // message is deleted by sina
        if (msg.getUser() == null) {
          iterator.remove();
        } else {
          msg.getListViewSpannableString();
          TimeUtility.dealMills(msg);
        }
      }
    } catch (JsonSyntaxException e) {

      AppLoggerUtils.e(e.getMessage());
    }

    return value;
  }