我试图在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");
}
}
请问如何通过以下尝试获得关注者数量
答案 0 :(得分:0)
尝试
double amountOfFollowers = json.getDouble("followers_count");