Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook Graph API - access the comments and their replies with one query

The following Facebook Graph API v2.6 query:

/{{POST_ID}}/?fields=comments.summary(true)&access_token={{ACCESS_TOKEN}}

will get the comments (with theirs IDs) for the specified Post. Then the query

/{{COMMENT_ID}}/?fields=comments.summary(true)&access_token={{ACCESS_TOKEN}}

will get the replies for the specified Comment.

Is there a way to get both the comments and their replies for given Post with one Graph API query?

like image 743
Nikola Obreshkov Avatar asked Jun 03 '16 07:06

Nikola Obreshkov


2 Answers

This will get u the comment replies of comments.

/{{POST_ID}}/?fields=comments{comments}&access_token={{ACCESS_TOKEN}}

You can get any sub info(from,id) of comment replies by just nesting fields inside comments like this:

/{{POST_ID}}/?fields=comments{comments,from,id}&access_token={{ACCESS_TOKEN}}

You can always try out any kind of query at :

https://developers.facebook.com/tools/explorer/

In case you have any doubt on how to form any query, this tool has a search filter on left in which you enter the fields you require and it will automatilcally generate the query for you.

like image 175
sujit Avatar answered Oct 12 '22 01:10

sujit


I believe this is what you're looking for: https://graph.facebook.com/{the_page_id}_{your_post_id}/comments?fields=message,comments{message,comments}&access_token={your_api_key}

like image 30
Jonjon C. Botelho Avatar answered Oct 12 '22 00:10

Jonjon C. Botelho