With the new "Reply" to "Comments" feature on Facebook, I've noticed that replies to comments are treated the same as comments. But I was wondering if there is anyway to distinguish the two?
5 Answers
You first have to enable July Breaking Changes
from your app advanced settings
Then use the fields
parameter with the comments
graph API and include the parent.field(id)
column with the and also the filter
parameter with the stream
value. the final result :
{POST_ID}/comments?filter=stream&fields=parent.fields(id),message,from,likes
this should return both comments and replies with the parent
element which has the comment id that the reply belongs to
-- update
and for better array arrangement for replies you can use the following to merge replies with the actual comment array you can include comments.summary(true)
in the fields parameter
{POST_ID}/comments?limit=0&filter=toplevel&fields=comments.summary(true),message,from,likes
filter parameter is optional
for more info about the fields : http://developers.facebook.com/docs/reference/api/Comment/
and in case you want to do it in FQL, check this post's comments http://developers.facebook.com/blog/post/2013/04/03/new-apis-for-comment-replies/

- 1,922
- 7
- 30
- 51
-
The updated version of this works great, although I had to take out 'limit=0' – Gav Sep 18 '15 at 11:25
Yes. You can query each comment
object in the Graph API for the value of its parent
field. If the comment in question is a reply, then the value of the parent
field will be a reference to the parent comment. Otherwise, no value is returned.
Reference here: https://developers.facebook.com/docs/reference/api/Comment/

- 2,511
- 1
- 12
- 10
-
2Seems like Facebook's API has been modified over the past few days, I can no longer get the replies to comments in the same place where I would get the comments to the post. I now have to send a separate request to the /
/comments to get the replies. I liked the old way better, if they could just add the parent id right there. But oh well... – Roozbeh15 Apr 05 '13 at 18:01 -
2This is ridiculous that i have to query each comment to know whether its reply or not, why can't they just include the "parent" value in the `/comments` api itself ? – Osa May 12 '13 at 22:41
You can get comment replies in this way.
/{{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}}
Similar post over here : https://stackoverflow.com/a/37743410/6001533
If you're listening for comments on the 'feed' webhook, you should check if:
entry[0][changes][0][value][post_id] === entry[0][changes][0][value][parent_id]
This will be true for top-level (new) comments, and false for replies to comments.

- 437
- 4
- 14
To piggy back off @sujit's answer I took his answer and in one call from the feed you can get the entire feed, comments and replies to comments as well as associated images to those comments and replies in one shot.
Here is the code
https://graph.facebook.com/$get_facebook/feed?access_token=$facebook_accesstoken&client_id=$facebook_appid&client_secret=$facebook_appsecret&metadata=1&fields=id,status_type,created_time,from,message,comments{comments{attachment,from,id,message},from,id,message,attachment},picture,link,icon

- 4,754
- 9
- 39
- 81