我正在开发一个 iOS 应用程序,其中包括用户墙的 facebook 提要。使用带有以下 URL 的图形 api:
feedURL = [NSString stringWithFormat:@"https://graph.facebook.com/%@/feed?
access_token=%@&since=%@&until=%@",kFaceBookID,FBSession.activeSession.accessToken,
[dateRange objectForKey:@"since"], [dateRange objectForKey:@"until"]];
我得到的数据只有一个结果和一个用于分页的字典条目。当我使用“下一个”URL 执行 NSURLRequest 时,我得到 0 个结果。如果我将相同的 URL 剪切并粘贴到网络浏览器中,我会得到 25 个结果。关于为什么的任何想法?
这是我正在使用的代码:
- (void)connectionDidFinishLoading:(NSURLConnection *)connection
{
NSString *nextPageURL;
NSError *jsonError;
if (!jsonError) {
NSDictionary *rDict = [NSJSONSerialization JSONObjectWithData:_postData
options:0
error:&jsonError];
nextPageURL = [[rDict objectForKey:@"paging"]objectForKey:@"next"];
NSArray *rArray = [rDict objectForKey:@"data"];
DLog(@"Posts Dictionary = %@\n\n",rDict);
for (NSDictionary *rPost in rArray) {
FBPost *post = [[FBPost alloc]initFBPostWithDictionary:rPost];
[feedsArray addObject:post];
}
}
else
{
ALog(@"json error = %@",[jsonError localizedDescription]);
[activity stopAnimating];
NSString *errorMessage = [NSString stringWithFormat:@"Facebook status request failed with error: %@\nCheck your network connection and try again later",[jsonError localizedDescription]];
[self quit:errorMessage];
}
[feedsTable reloadData];
if (nextPageURL && [feedsArray count] < 30) {
DLog(@"Next Feed URL = %@",nextPageURL);
NSURLRequest *request = [NSURLRequest requestWithURL: [NSURL URLWithString:nextPageURL]];
if (![[NSURLConnection alloc] initWithRequest:request delegate:self]) {
ALog(@"Connection failed for request: %@",request);
}
}
}