Reputation: 39389
I have an access token for a page on Facebook. I can view that page’s feed, and individual posts in that feed. But for some reason, I can only request the /sharedposts
endpoint for some of them using v2.2 of the Graph API.
The access token has the user_posts
and read_stream
insights. When I request the shares
field I can see more than one post with shares, but when I request [POST_ID]/sharedposts for some of them, I just get an empty data
array in response.
Why is this? Are there some gotchas I should be aware of? It’s a tad frustrating that the /sharedposts
edge will return returns for some posts but not others using the same access token and API version.
Upvotes: 1
Views: 914
Reputation: 1
I just posted my insight/workaround for this bug on the bug report that lars.schwarz linked to, but I'll paste it here as well:
/sharedposts will only retrieve public posts or posts from users who have granted your app access. HOWEVER, the endpoint does not seem to query for this intelligently. I'm not sure, but I think the endpoint has a default limit of 25 results. What appears to be happening is that the endpoint queries Facebook's database for 25 posts, then filters that set based on your app's permissions.
What this means is that if the most recent sharedpost your app is allowed to access is 30 posts deep, the endpoint will return an empty data set. If your app is allowed to access one post which is 15 deep, and one that is 30 deep, it will only return the post that is 15 deep.
In order to get around this, you can set a really high limit (I've been using 2000). The problem with this is that if your post has more than 2000 shares, you will still miss stuff. You can't make the limit insanely high, unfortunately, because the endpoint will return an error telling you to query for less data (even if the query would only actually return a handful of posts). Therefore, I've been setting a limit of 2000 and using the "until" parameter to move through the sharedposts chronologically.
Hopefully that helps clear things up. This is a major pain, and an imperfect solution (although it gets 99% of the job done I think). I encourage everyone to file a bug report on this here: https://developers.facebook.com/bugs
It appears that this bug has been around for years, and I was told yesterday that they have no short-term plans to fix it. If we file enough complaints, maybe they'll prioritize it higher.
Upvotes: 0
Reputation: 1274
This is a know bug, which still seems to be unsolved.
Basically it should work like you expected, but even with all necessary permission (and even for public posts) it does not return the object with each of the shares.
You probably want to subscribe to the bug here to be noticed once it has been solved:
https://developers.facebook.com/bugs/1404733043148335/
Upvotes: 0