Facebook Graph API: Find graph object from post URL
Asked Answered
V

2

10

Given the URL of a public Facebook post, how can one find the post object in the FB Graph API? (secondarily, why are so many user feeds empty or nearly empty when accessed through the API?)

We would like to be able to comment on or like a post via the v2.x Graph API, given the post's URL. Doing so requires the post's object ID, which we can make some educated guesses about, but accessing the actual object through the API has proven unreliable (works for some posts but not others).

v2 of the API introduced app-scoped user IDs, and post IDs generally seem to be of the form {app-scoped user id}_{unique post id}. Here are the details of some attempts to find posts in the API with various combinations of these IDs (global user id, app-scoped user id, and post id).

OK let's try the other direction. We'll page through the user's feed until we find the post in question. It feels like this is more the expected use case for the API...

For reference, here is the GitHub issue where we have been tracking this problem.

Vitek answered 5/2, 2015 at 6:12 Comment(3)
Correct is that with API v2, there is no username field any more, and your app will not be allowed to use the global user id to request user details any more either, only the app-scoped user id. What I am wondering here, is why is there a need to request post details based on a post URL in the first place? Normally your app should work with data that it requested via API before already, so “external” URLs like this would not come into play in the first place.Archiphoneme
The goal is for someone to post a reply to or like of a FB status on their own personal website, and then use an app to publish it to Facebook. More details here: brid.gy/about#publishing.Vitek
try my answer maybe it will put you in right directionAleta
A
3

Basically you would need read_stream for this (which your app will not get granted). And yes, even though the post is public, you still need read_stream to be able to get read access to all kinds of posts.

You can easily play around with this in Graph API Explorer. First give your app read_stream permission to get ids of items in your feed – that will give you ids of the “form app-scoped user id underscore post id”. Then remove read_stream (by clicking “Get Access Token” again and using the “Clear” button), and try several of the user_* permissions – and you will see that for most of your posts, even the public ones, you will still only get “Unsupported get request”, which just means you are not allowed to read that object.

F.e., I have a public post where shared a video post from another page on my timeline, the type is video and status_type is shared_story, but neither user_status nor user_videos allow me to read this post – only when I grant read_stream again, my app can read that post. Same with another public post of type status and status_type mobile_status_update – readable with read_stream, not with any of the user_* permissions.

In short: What you want to achieve is not possible any more with API v2 and the restriction that read_stream will only be granted to apps on platforms where no official FB client exists.

Archiphoneme answered 14/2, 2015 at 13:25 Comment(3)
Thanks for the response, I'm going to go ahead and send you the bounty because it's expiring otherwise. So I actually think our app was grandfathered in on read_stream, it seems to have it at least for now. Do you know if that should that let me see all posts, or just my friends' posts, or just my own?Vitek
According to developers.facebook.com/docs/graph-api/reference/v2.2/user/feed only posts by people that have granted your app read_stream will be visible to your app when requesting a user’s feed (which would be the user’s own posts, and posts made by others on the user’s timeline). And after April 30, 2015 your app will not be able any more to ask people for any permission (besides the ones for user profile, friends and email) without your app undergoing review by FB first – and read_stream will not be granted to any app on a platform for which an official FB client exists.Archiphoneme
yup, this is basically the same conclusion we came to in github.com/snarfed/activitystreams-unofficial/issues/26 . sigh. :(Maite
A
0

A one proposition is to make api calls to write facebook posts since those return valid post_id that you could use

Second, When you try https://developers.facebook.com/tools/explorer/256884317673197/?method=GET&path=525575504%2Fposts&version=v2.0&

You can see that his posts ID's are not starting with his public id as you wrote 525575504_*

but they still put unsupported get request

https://developers.facebook.com/tools/explorer/256884317673197/?method=GET&path=10152853212485505_351575675029953&version=v2.0

Third since above doesnt work are those posts public for sure?

Aleta answered 14/2, 2015 at 0:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.