Find user ID from comment on a post in Facebook Page?

Viewed 7907

https://developers.facebook.com/docs/graph-api/reference/v2.11/comment

In this, there is no field to find the user who is made the comment. However, this is publicily available on facebook but graph API doesn't allow it.

For example, if get the comment id 124125235235_124242353254, there what can I do to find the user who commented it?

graph.facebook.com/5550296508_10157585378836509?fields=comments&access_token=XXX

1 Answers

Starting from Graph API v2.11, you need a page access token to get the (scoped) user_id from any endpoint (comments and reactions, for a start).

(See v2.11 90 Days Breaking Changes)

/page/* — User information will not be included in GET responses for any objects owned by (on) a Page unless the request is made with a Page access token. This affects all nodes and edges that return data for objects owned by a Page.

This is already happening to API calls made with 2.11 prefix. E.G.

https://graph.facebook.com/v2.11/5550296508_10157585378836509?fields=comments&access_token=XXX

You can still go to the Graph API Explorer and taylor your request to be made against an older endpoint or build your own request as

https://graph.facebook.com/v2.10/5550296508_10157585378836509?fields=comments&access_token=XXX

However, IIRC, 90 Days Breaking Changes means that in 90 days this policy will affect all API versions, so older apps will no longer return the user ids.

How do you get a page token?

In the Graph API Explorer you can generate tokens for the pages you have access to.

And to get access to a page, you need to be authorized by a page admin. He can authorize you by going to his page, then click on settings -> page roles.

enter image description here

I guess you need the least privilege to actually get scoped user_ids.

Related