我希望逐页获取Facebook好友。这可能吗?
答案 0 :(得分:3)
实施分页的最佳方式: 当你得到第一个响应时,从Response对象中检索下一页Request对象。然后在您想要获取下一页数据时执行该请求
Response response = yourFirstRequest.executeAndWait();
//getRequestForPagedResults() returns null if there is no more paging, you can get previous page request with parameter PagingDirection.PREVIOUS
Request nextPageRequest = response.getRequestForPagedResults(PagingDirection.NEXT);
//以及之后您想要下一页信息
nextPageRequest.executeAndWait();
答案 1 :(得分:2)
在脸谱图api中试试这个
https://graph.facebook.com/me/friends?limit=1
Bundle params = new Bundle();
params.putString("limit", "1");
Request tagRequest = new Request(Session.getActiveSession(), me/friends, params, HttpMethod.GET, new Request.Callback() {
@Override
public void onCompleted(Response response) {
//here you can get your friends in json data. and also "paging" with "next" tag.
GraphObject graphObject = response.getGraphObject();
JSONObject jsonObject = graphObject.getInnerJSONObject();
String next = jsonObject.getJSONObject("paging").getString("next");
}
//for next friend
// before using next remove the graph api path from it. i.e "https://graph.facebook.com/"
Request.executeGraphPathRequestAsync(Session.getActiveSession(), next, new Request.Callback() {
@Override
public void onCompleted(Response response) {}