Facebook Graph API: Find graph object from post URL - facebook

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).
Starting with a simple example: https://www.facebook.com/evan.prodromou/posts/10153023417510505. Key characteristics are that it's public, it's not a share of another post, and most importantly it has no photo(s), which add extra ids and URLs for the individual photo(s) and photo set. Evan's profile is also public, i.e. https://www.facebook.com/evan.prodromou doesn't show the generic This content is currently unavailable
Trying the bare post id from that URL, /v1.0/10153023417510505 and /v2.2/10153023417510505 both give the Unsupported get request (code 100) error.
Evan's global user id is 525575504. Attaching that as a prefix, /v1.0/525575504_10153023417510505 and /v2.2/525575504_10153023417510505 still both give the same Unsupported get request error.
Same error using his app-scoped user id instead, /v2.2/10152350676805505_10153023417510505.
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...
Both the global /v2.2/525575504/posts and app-scoped /v2.2/10152350676805505/posts return nothing, but /v1.0/525575504/posts returns two recent posts, this like and this post. Not sure why only those two, even though has plenty of other recent public posts. The like is fetchable via its id field in both api versions, i.e. /v1.0/525575504_10153045879215505 and /v2.2/10152350676805505_10153045879215505, but both API versions return the Unsupported get request error when fetching the post via its id field, e.g. /v1.0/525575504_351575675029953 and /v2.2/10152350676805505_351575675029953
Trying another public post, this one with pictures: https://www.facebook.com/andigalpern/posts/678121182314631 . /v1.0/100003502653187_678121182314631, /v2.2/100003502653187_678121182314631, and /v2.2/499657186827699_678121182314631 all error.
/v1.0/100003502653187/posts only includes one post, a like, and /v2.2/100003502653187/posts is empty.
For reference, here is the GitHub issue where we have been tracking this problem.

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.

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?

Related

Why does /{usr-id}/feed return an empty result in Facebook API v2.4?

UPDATE:
There must have been a caching issue (for the token/page). Now that I try I get a consistent response for both versions (empty list). Unless my friend also uses the app, it can't fetch their activities.
I'm testing in Graph explorer (https://developers.facebook.com/tools/explorer/), with a token that has user_status and user_post.
Calling /v2.4/10153373299959566/feed?fields=id,message,picture,likes,shares,comments
returns an empty list, while the same thing using v2.3 returns posts of that user.
Is there anything I'm missing?
I read the upgrade guide in https://developers.facebook.com/docs/apps/upgrading but couldn't find anything.
Does new API only return my own feed, and not my friends?

Facebook graph api - Unsupported get request

I'm creating a custom module in Drupal, that for part of its functionality must fetch posts from a business page. So for simplicity, I'm using fbapp module as a dependency (drupal.org/project/fbapp), so that I can use it's authentication and request functions (fbapp_app_authenticate() and fbapp_graph_request()) without having to worry about the constant facebook graph updates making my own code obsolete.
I've created a facebook app, so authentication should be app token, using appid and app secret. This seems fine and I'm getting back access_token. However, when I try to read posts from a publicly available page (the clients), I get the response:
"Unsupported get request. Please read the Graph API documentation at https:\/\/developers.facebook.com\/docs\/graph-api"
Here's the queries and responses my code produces:
graph.facebook.com/oauth/access_token?client_id=<redacted>&client_secret=<redacted>&grant_type=client_credentials
array(1) {
["access_token"]=>
string(43) "<redacted>|<redacted>"
}
graph.facebook.com/<page_id>/posts?access_token=<redacted>|<redacted>"
string(183) "{"error":{"message":"Unsupported get request. Please read the Graph API documentation at https:\/\/developers.facebook.com\/docs\/graph-api","type":"GraphMethodException","code":100}}"
Can anyone verify a correct way to query a Facebook page programmatically, perhaps there's a setting in the page I'm querying that I need to set (although I can't find anything)?
If page restrictions apply, the page's feed can only be retrieved with an user access token as far as I know (because FB needs to evaluate the visibility criteria, and setting your app to the same restrictions doesn't help here):
See
https://developers.facebook.com/docs/graph-api/reference/v2.4/page/feed#readperms
It looks like everything you have done is correct. The response you got can be (i am not sure) because you got your clients pageid wrong.

Understanding Facebook Graph API identifiers

While I do realize that the ids for graph api objects are not documented, I'm seeing some oddities which I'd like to understand.
I have an authorized app that polls a page's feed for new comments and it looks like I'm getting different ids for the same post.
On first run I get a post with the id of:
1470990656482896_1553567768225184
Which is the id of the page and post joined by an underscore.
The second poll which ran a few minutes later, I received the same post with a different id:
100008124617959_1553567768225184
Which is the user id of the poster and post joined by an underscore.
While I'd like to understand the inconsistency, the real problem is trying to access the post via the second identifier returns an Unsupported get request with the code of 100
The post is public and is accessible via both
https://www.facebook.com/100008124617959/posts/1553567768225184
and
https://www.facebook.com/1470990656482896/posts/1553567768225184
This sounds like an oauth problem. While the post is public, to access it via the graph API you have to use an access token.
If you use the access token for Hans Gotwo then you should be able to access the post with the id of 100008124617959_1553567768225184
Looks like it's a bug. thanks #phwd
https://developers.facebook.com/bugs/721538487964698/

Facebook Graph API: find all public pages I like in a single request

I would like to know which objects returned from /me/likes are public ie. don't require authorization.
So far, I haven't found a better solution than making another request to /?ids=<IDs> without the access token, where <IDs> is a comma-separated list of IDs obtained from the previous request.
Is there any field indicating whether an object is public? Any help will be highly appreciated!
This is a matter of what you're asking for when you get the auth toke. If you have all boxes unchecked you will get just public information from the request. You'll know this by the pop-up asking for authorization saying
"Graph API Explorer will receive the following info: your public profile."
How ever if you have the box checked that says "user_likes" you'll get a list of all the likes. The authorization will say.
"Graph API Explorer will receive the following info: your public profile and likes."
If you just want to return the id of the things you like you can use this.
me?fields=likes{id}

How to delete a Facebook comment post using the Facebook GRAPH API?

I started researching this because I wanted to be able to delete a comment on the wall of a Facebook Event, because the "Remove post" doesn't seem to be applicable to comments on an Event wall. However, since I don't know if it is even possible I decided to see if I could mannually delete a post I made to my own wall first since that is possible. Note I am NOT using any SDK; I am just building the URL and entering it in the address bar in Firefox v3.6.17.
These posts have helped me alot since I am now starting:
Delete facebook post with Graph API - trouble getting this to work and
Facebook SDK and Graph API Comment Deleting Error
I can see the comment data and all its field via the following:
https://graph.facebook.com/[POST_ID]?access_token=[ACCESS_TOKEN]
`where [POST_ID] and [ACCESS_TOKEN] were got using the graph API.`
However, where do I put the "method=delete" command in the URL? I tried putting it at the end, like
https://graph.facebook.com/[POST_ID]?access_token=[ACCESS_TOKEN]?method=delete
but that results in a OAuthException stating "Invalid access token signature" because it seems to read the method as part of the access token.
I tried putting it after the post_id like
https://graph.facebook.com/[POST_ID}?method=delete?access_token=[ACCESS_TOKEN]
but that results in an Exception (Unsupported method) because it thinks "access_token=[ACCESS_TOKEN]" is part of the method being called.
I see one of the posts cited above states I have to prepend the userid to the object ID when deleting by using
DELETE https://graph.facebook.com/673509687_104812882909249?access_token={access_token}
`where 673509687 is my userID and 104812882909249 is the objectID`
But when I enter
DELETE https://graph.facebook.com/[POST_ID}?access_token=[ACCESS_TOKEN]
in the Firefox address bar it doesn't recognize it (I didn't think it would anyway) and uses it as a google search query.
How do I delete a comment if I have the comment_id and my access_token using the web browser?
You have a big problem with your urls :
https://graph.facebook.com/[POST_ID]?access_token=[ACCESS_TOKEN]?method=delete
Should be :
https://graph.facebook.com/[POST_ID]?access_token=[ACCESS_TOKEN] & method=delete
Identically,
https://graph.facebook.com/[POST_ID}?method=delete?access_token=[ACCESS_TOKEN]
should be :
https://graph.facebook.com/[POST_ID}?method=delete & access_token=[ACCESS_TOKEN]
So you have to use the ? before entering your parameters and then & between each parameter and the order should not have any importance ..