Facebook API分页不起作用 [英] Facebook API Pagination doesn't work

查看:166
本文介绍了Facebook API分页不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Facebook SDK 3.10.0 for iOS。当我试图获取用户的新闻源时,我有一个问题:
在Facebook的请求:

  [FBRequest requestForGraphPath:@我/ home] 

我收到所有需要的数据和有关信息的回复分页:

  data =(
一大堆用户数据
);
paging = {
next =https://graph.facebook.com/{MY_USER_ID}/home?format=json&access_token={ACCESS_TOKEN}&limit=25&until=1385113385;
previous =https://graph.facebook.com/{MY_USER_ID}/home?format=json&access_token={ACCESS_TOKEN}&limit=25&since=1385206398&__previous=1;
};

但是当我尝试使用下一个链接获取信息时, AFHTTPRequestOperation

  AFHTTPRequestOperation * newDataOperation = [[AFHTTPRequestOperation alloc] initWithRequest:request]; 
newDataOperation.responseSerializer = [AFJSONResponseSerializer serializer];
[newDataOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation * operation,id responseObject){
NSLog(@%@,responseObject);
} failure:^(AFHTTPRequestOperation * operation,NSError * error){
NSLog(@Next page retrieval error =%@,error);
}];

我得到空json

  data =(
);

我使用Facebook访问令牌调试器和结果:





并且有奇怪的事情访问令牌,我得到使用Graph Api Explorer不同于我在我的应用程序。我从Graph Api Explorer获取的令牌非常好,但是当我从应用程序结果中得到tesetd令牌时:我/ home 工作

next 链接返回空:



< img src =https://i.stack.imgur.com/9NPME.pngalt =enter image description here>

解决方案

 有奇怪的事情访问令牌,我使用Graph Api Explorer 
不同于我在我的应用程序。

其实并不奇怪。访问令牌将根据您从资源管理器右上角选择的应用程序类型而有所变化。

  Facebook API分页不起作用

我在Graph API中看到了很多有关分页问题的问题奇怪的是,问题还没有解决!您可以尝试使用基于偏移的分页。例如,在URL中设置 limit = 100& offset = 0 。我知道这在新闻Feed的情况下是没有意义的,但是在大量数据的情况下通常可以正常使用。


I use Facebook SDK 3.10.0 for iOS. When i'm trying to get user newsfeed, i've a problem: On facebook request:

[FBRequest requestForGraphPath:@"me/home"]

i get response with all data that i need and info about paging:

data = (
    "A LOT OF USER DATA"
);
paging =     {
    next = "https://graph.facebook.com/{MY_USER_ID}/home?format=json&access_token={ACCESS_TOKEN}&limit=25&until=1385113385";
    previous = "https://graph.facebook.com/{MY_USER_ID}/home?format=json&access_token={ACCESS_TOKEN}&limit=25&since=1385206398&__previous=1";
};

but when i trying to get info using next link and AFHTTPRequestOperation:

AFHTTPRequestOperation *newDataOperation = [[AFHTTPRequestOperation alloc] initWithRequest:request];
    newDataOperation.responseSerializer = [AFJSONResponseSerializer serializer];
    [newDataOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
        NSLog(@"%@", responseObject);
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        NSLog(@"Next page retrieving error = %@", error);
    }];

i get empty json

data =     (
);

i've using Facebook Access Token Debugger and result:

And there is strange thing access token which i get using Graph Api Explorer differs from which i get in my app. Token which i get from Graph Api Explorer works perfectly fine but when i tesetd token from app results the same: me/home working but next link returns empty:

解决方案

And there is strange thing access token which i get using Graph Api Explorer
differs from which i get in my app.

It's actually not strange. The access token will change depending on the type of application you've selected from the top right corner of the explorer.

Facebook API Pagination doesn't work

I've seen a lot of questions about the pagination problem in the Graph API and it's strange that the problem hasn't been fixed yet! You can try using the Offset based pagination. For example, setting limit=100&offset=0 in the URL. I know this doesn't make sense here in case of news feed, but it usually works fine in case of large volume of data.

这篇关于Facebook API分页不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆