使用facebook sdk 3.0.1 Android为facebook好友列表实现分页
我想一页一页地获取Facebook好友。有可能吗?在Facebook graph api中尝试此功能使用facebook sdk 3.0.1 Android为facebook好友列表实现分页,android,facebook,Android,Facebook,我想一页一页地获取Facebook好友。有可能吗?在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, para
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) {}
在facebook图形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) {}
实现分页的最佳方法: 当您得到第一个响应时,从响应对象中检索下一个页面请求对象。然后,当您想要获取下一页数据时,执行该请求
Response-Response=yourlistrequest.executeAndWait();
//getRequestForPagedResults()返回null如果没有更多分页,则可以使用参数PagingDirection.previous获取上一页请求
Request nextPageRequest=response.getRequestForPagedResults(PagingDirection.NEXT)代码>
//当你想要下一页信息时
nextPageRequest.executeAndWait()代码>实现分页的最佳方法:
当您得到第一个响应时,从响应对象中检索下一个页面请求对象。然后,当您想要获取下一页数据时,执行该请求
Response-Response=yourlistrequest.executeAndWait();
//getRequestForPagedResults()返回null如果没有更多分页,则可以使用参数PagingDirection.previous获取上一页请求
Request nextPageRequest=response.getRequestForPagedResults(PagingDirection.NEXT)代码>
//当你想要下一页信息时
nextPageRequest.executeAndWait()代码>虽然此链接可以回答问题,但最好在此处包含答案的基本部分,并提供链接以供参考。如果链接页面发生更改,仅链接的答案可能会无效。facebook graph api将“分页”作为标记。e、 g“paging”:{“next”:“”},在这里您可以设置限制,通过点击上面的请求可以获得剩余的项。不要忘记从请求中删除“”,因为facebook sdk会将此url本身粘贴为图形api路径。我正在编辑我的答案以获取更多详细信息。要求已更改,因此我尚未尝试此解决方案。感谢您的帮助。虽然此链接可能会回答此问题,但最好在此处包含答案的基本部分,并提供此链接以供参考。如果链接页面发生更改,仅链接的答案可能会无效。facebook graph api将“分页”作为标记。e、 g“paging”:{“next”:“”},在这里您可以设置限制,通过点击上面的请求可以获得剩余的项。不要忘记从请求中删除“”,因为facebook sdk会将此url本身粘贴为图形api路径。我正在编辑我的答案以获取更多详细信息。要求已更改,因此我尚未尝试此解决方案。感谢您的帮助。