I have tried querying statuses, likes, photos, everything works fine.
But when i add a limit "?limit=100" to the end of the string, I get an error from the Response object with errorType: OAuthException, errorMessage: An active access token must be used to query information about the current user
The relevant sections of my code is below:
Request rq3 = new Request(Session.getActiveSession(), "/me/statuses?limit=100", null, HttpMethod.GET, new Request.Callback() {
@Override
public void onCompleted(Response response) {
parseFeed(response, 2);
getNext(response, 2);
}
});
rq3.executeAsync();
private void parseFeed(Response response, int type) {
try {
Log.v("response", response.toString());
JSONArray feedArr = response.getGraphObject().getInnerJSONObject().getJSONArray("data");
switch(type) {
case 0:
numLikes += feedArr.length();
likesView.setText("Likes: " + String.valueOf(numLikes));
break;
case 1:
numPhotos += feedArr.length();
photosView.setText("Photos: " + String.valueOf(numPhotos));
break;
case 2:
Log.v("response", response.toString());
numStatuses += feedArr.length();
statusesView.setText("Statuses: " + String.valueOf(numStatuses));
break;
}
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
private void getNext(Response response, final int type) {
Request next = response.getRequestForPagedResults(Response.PagingDirection.NEXT);
if (next != null) {
Log.v("status", "getting next");
next.setCallback(new Request.Callback() {
@Override
public void onCompleted(Response response) {
// TODO Auto-generated method stub
parseFeed(response, type);
getNext(response, type);
}
});
Request.executeBatchAsync(next);
}
else {
Log.v("status", "ended");
}
}
Request(Session, String, Bundle, HttpMethod, Callback)
parameters Additional parameters to pass along with the Graph API request; parameters must be Strings, Numbers, Bitmaps, Dates, or Byte arrays.
According to the doc , parameters should not be part of the graph path. You are actually passing a null
Bundle
.
The right usage:
Bundle params = new Bundle();
params.putString("limit", 100);
Request rq3 = new Request(Session.getActiveSession(),
"/me/statuses",
params,
HttpMethod.GET,
new Request.Callback() {
@Override
public void onCompleted(Response response) {
parseFeed(response, 2);
getNext(response, 2);
}
}
);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.