问题
I searched through all the posts about Facebook graph API and didn't find anything about it. Here's the issue.
I'm working on the iPhone app for one company. And for the news section in this app, i'm pulling all the posts and comments from the wall of this company's Facebook page using Facebook graph API. The way i do this is: first i pull all the posts by sending request:
[facebook requestWithGraphPath:@"company name/feed" andDelegate:self];
And I receive the NSDictionary with all posts and information about it, including number of comments. I put all the post in tableView and when you tap one of the posts viewController of comments opens. Where i requesting the comments for this post:
NSString *postId = [self.post objectForKey:@"id"];
NSString *request = [NSString stringWithFormat:@"%@/comments" ,postId];
[facebook requestWithGraphPath:request andDelegate:self];
I'm receiving the array of comments. But some of them are missing. I guess it because of some privacy setting people have in their accounts.
I'm just wondering maybe someone had the same issue and know how to work this around. Or know what privacy settings user need to change in his facebook account to be able to see his comments.
Thanks.
回答1:
Just wanted to add this works: Grab the feed for all the basic wall post information, then grab the comments for each post individually. Requires more complex refresh methods, and a little trickery (trust your comments array over the JSON comment count number where you can) but at least it gets it right.
I was grabbing the feed to get post_id's, then grabbing each post individually to get the correct information. However, just 2 days ago I had some really funny stuff going on where the same facebook post request in iOS would return 2 of the 3 comments, the Chrome browser returned 1 comment (the latest one) and the request in Firefox returned the other 2 comments but not the newest one. Didn't matter if I was logged in or not when using the browser to test the response. This happened for about half the posts with comments.
So I tried using the access token in the URLs on the Facebook Developers site and changing the request to this particular post - returned all the correct information straight away! It got to the point where I even created a new Facebook App to get a new app ID, and a fresh project in XCode to eliminate all possibilities - didn't make a difference.
So thanks to this thread I tried the {post_id}/comments GET, and it works correctly. I've done the same thing for likes to eliminate that potentially breaking further down the line as well!
回答2:
The Graph API works in mysterious ways and there's a countless number of bugs actually open, but to make it simple you'll need to pass a valid access_token to retrieve all comments from facebook.
Meaning https://graph.facebook.com/page_id/feed?access_token=blah
The API will return a JSON with links to use the pagination. You can use them to browse through or retrieve directly a larger amount of data:
https://graph.facebook.com/page_id/feed?access_token=blah&limit=1000
Note that using a limit higher than 1000 will lead to bugs and possible invalid data... that's a known bug. There are also bugs in the pagination logic that might or might not be fixed as of 2011... you'll have to check.
The comments count and actual count is also buggy and might be off when working on large pages (seen it happen on pages with more than 5k comments per post). There are also some problems with getting the count itself...
Sorry if I can't help you more than that, but the graph API is still a bit of a mess and counts a fairly high number of bugs. You'll have to try and see if it works as explained in the documentation. But definitively add an access token, it can't hurt and you'll most likely get the data you want... unless you run into a bug.
回答3:
Furthermore, the number of comments is sometimes different in /feed then in /post_id/comments
For instance :
graph.facebook.com/146154582080623/feed returns 1 comment with a count of 3
and
graph.facebook.com/146154582080623_184735008222580/comments (which is a post of the previous page) returns 2 comments
So I'm wondering if privacy is the problem or not.
来源:https://stackoverflow.com/questions/4393137/not-all-the-comments-visible-when-pulling-a-post-using-facebook-graph-api-iphone