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

眉间皱痕 提交于 2019-12-05 07:14:18

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.

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}

use filter=stream parameter

https://graph.facebook.com/post_id/comments?access_token=XXXXXXfilter=stream

if you want parent comment id, use fields=parent.fields(id) parameter

https://graph.facebook.com/post_id/comments?access_token=xxxxxx&filter=stream&fields=parent.fields(id)

According to my research you can get post comments and their replies in one query. You can get all comments of post using following API through graph explorer or curl request. Replace {your post id} including braces with your post id.

If you are using graph api explorer then generate page access token to test this API. If you are using curl request that append page access token at the end of URL.

https://graph.facebook.com/v2.10/{your post id}?fields=comments

You can get all replies on all comments of post using following API. It will give you json data containing comment id and all replies to each comment.

https://graph.facebook.com/v2.10/{your post id}?fields=comments{comments}

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!