试图从twitter api获得粉丝数量 - android

时间:2017-05-10 23:38:28

标签: android json twitter

我试图在json调用twitter api后进行身份验证后获得关注者数量。 api调用是成功的,但挑战是如何从json成功调用中检索关注者的数量。以下是我的尝试

private void getUserSettings(){
        try {
            consumer.setTokenWithSecret(ACCESS_KEY, ACCESS_SECRET);
            String a = consumer.sign(URL_GET_USER_SETTINGS);
            HttpGet get = new HttpGet(a);
            HttpClient c = new DefaultHttpClient();
            HttpResponse resp = c.execute(get);
            StatusLine statusLine = resp.getStatusLine();
              int statusCode = statusLine.getStatusCode();
              if (statusCode == 200) {
                JSONObject json = readJSONResponse(resp);
                twitterName = (String)json.get("screen_name");
              } else {
                Log.e(TAG, "Failed Get Twitter info");
              }
        } 

请问如何通过以下尝试获得关注者数量

1 个答案:

答案 0 :(得分:0)

尝试

double amountOfFollowers = json.getDouble("followers_count");