2
votes

I need to fetch the most recent comment(persons picture, name and comment) for a given url via the facebook graph api.

I have tried graph.facebook.com/v2.7/{object-id}/comments where I replace {object-id} with my site url, url encoded.

The problem is the graph api thinks that /comments portion is part of the url.

If I do graph.facebook.com/v2.7/?id=myurlhere.com then it at least returns the correct comment count and share count but I have yet to figure out how to request the actual comments.

I have tried using graph.facebook.com/v2.7/{object-id}/comments with the actual object id returned by graph.facebook.com/v2.7/?id=myurlhere.com but of course that doubles the api calls I have to make. I also dont see any image listed along with the comments.

I'm getting closer graph.facebook.com/v2.7/899503886844396/comments?fields=message,from{name,picture}

Now if I can just figure out how to replace that object id with a url.

1
It isn't clear from the docs that there are comments on a URL object developers.facebook.com/docs/graph-api/reference/v2.7/url - Yuri Schimke
I'm going off of developers.facebook.com/docs/graph-api/reference/v2.7/object/… which looks to give comments for any id. - hcker2000
Does metadata=1 show the edge? Where do these comments show up on the Facebook website? - Yuri Schimke

1 Answers

3
votes

As mentioned in a comment it's a good idea to use metadata=1 to see what you perhaps will be able to find. That is /?id=yoururlhere&metadata=1 or /yoururlhere?metadata=1

One of the fields is an og_object. Then you have the comments like this /yoururlhere?fields=og_object{comments{message,from{name, picture}}}

(I learned a lesson, I hope, now edited my previos very first answer att stackoverflow.)