我想逐页获取Facebook好友。可以吗?
问问题
2637 次
2 回答
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();
于 2014-04-23T12:02:20.737 回答
2
在 facebook graph 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) {}
于 2013-05-30T12:29:14.017 回答