public String getUserFollowers() {
    OAuthRequest request = new OAuthRequest(Verb.GET, GET_FOLLOWERS_URL);
    this.service.signRequest(twToken.getAccessToken(), request);
    Response response = request.send();
    JSONObject res = null;
    JSONObject followers = new JSONObject();
    JSONArray followersList = new JSONArray();
    try {
      res = new JSONObject(response.getBody());
      JSONArray followersIDList = res.getJSONArray("ids");

      JSONObject other = null;

      for (int i = 0; i < followersIDList.length(); i++) {
        // System.out.println(friendsIDList.get(i).toString());

        other = getOtherProfileJson(followersIDList.get(i).toString());

        // System.out.println(other);
        if (!other.toString().contains("No user matches for specified terms"))
          followersList.put(other);
        followers.put("friends", followersList);
      }
    } catch (JSONException e) {
      response.getBody();
    }

    if (res != null)
      // return res.toJSONString();
      return followers.toString();
    else return null;
  }
 public TwitterConnectorImpl(String access_token, String identity) {
   this.twToken = new TwitterToken(access_token);
   this.service = twToken.getAuthService();
   this.name = ISocialConnector.TWITTER_CONN;
   this.id = this.name + "_" + UUID.randomUUID();
   this.access_token = access_token;
   this.identity = identity;
 }
 /*
  * Activities in Twitter is defined as tweets
  *
  * @see org.societies.api.internal.sns.ISocialConnector#getUserActivities()
  */
 public String getUserActivities() {
   OAuthRequest request = new OAuthRequest(Verb.GET, GET_TWEETS_URL);
   this.service.signRequest(twToken.getAccessToken(), request);
   Response response = request.send();
   JSONArray res = null;
   try {
     res = new JSONArray(response.getBody());
   } catch (JSONException e) {
     return response.getBody();
   }
   // System.out.println(res.toString());
   if (res != null) return res.toString();
   else return null;
 }
 public String getUserFriends() {
   OAuthRequest request = new OAuthRequest(Verb.GET, GET_FRIENDS_URL);
   this.service.signRequest(twToken.getAccessToken(), request);
   Response response = request.send();
   JSONObject res = null;
   try {
     res = new JSONObject(response.getBody());
   } catch (JSONException e1) {
     // TODO Auto-generated catch block
     e1.printStackTrace();
   }
   if (res != null) return res.toString();
   else return null;
 }
  public String getUserProfile() {
    OAuthRequest request = new OAuthRequest(Verb.GET, ACCOUNT_VERIFICATION);
    this.service.signRequest(twToken.getAccessToken(), request);
    Response response = request.send();
    JSONObject res = null;
    try {
      res = new JSONObject(response.getBody());
    } catch (JSONException e) {
      // TODO Auto-generated catch block
      return response.getBody();
    }

    if (res != null) return res.toString();
    else return null;
  }
 public JSONObject getOtherProfileJson(String id) {
   OAuthRequest request = new OAuthRequest(Verb.GET, GET_OTHER_PROFILE_URL + id);
   this.service.signRequest(twToken.getAccessToken(), request);
   Response response = request.send();
   JSONArray res = null;
   JSONObject user = null;
   try {
     res = new JSONArray(response.getBody());
     user = res.getJSONObject(0);
   } catch (JSONException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
   if (res != null) return user;
   else return null;
 }
  /* (non-Javadoc)
   * @see org.societies.api.internal.sns.ISocialConnector#post(java.lang.String)
   */
  @Override
  public void post(String activity) {

    JSONObject tweet = null;
    String res = null;
    try {
      tweet = new JSONObject(activity);
      OAuthRequest request = new OAuthRequest(Verb.POST, POST_TWEET_URL);
      if (tweet.has("status")) request.addBodyParameter("status", tweet.getString("status"));
      if (tweet.has("in_reply_to_status_id"))
        request.addBodyParameter("in_reply_to_status_id", tweet.getString("in_reply_to_status_id"));
      if (tweet.has("lat")) request.addBodyParameter("lat", tweet.getString("lat"));
      if (tweet.has("long")) request.addBodyParameter("long", tweet.getString("long"));
      if (tweet.has("place_id")) request.addBodyParameter("place_id", tweet.getString("place_id"));
      if (tweet.has("display_coordinates"))
        request.addBodyParameter("display_coordinates", tweet.getString("display_coordinates"));
      if (tweet.has("trim_user"))
        request.addBodyParameter("trim_user", tweet.getString("trim_user"));
      if (tweet.has("include_entities"))
        request.addBodyParameter("include_entities", tweet.getString("include_entities"));

      this.service.signRequest(twToken.getAccessToken(), request);
      Response response = request.send();

      res = response.getBody();

    } catch (JSONException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }

    if (res == null) System.out.println("failure");
    JSONObject resjson = null;
    try {
      resjson = new JSONObject(res);
      if (resjson.has("error")) {
        System.out.println(resjson.get("error"));
      }
      if (resjson.has("text")) {
        String resStatus = resjson.getString("text");
        if (resStatus.equalsIgnoreCase(tweet.getString("status"))) System.out.println("success");
      }
    } catch (JSONException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }