Retrieve Facebook Post Comments Using Graph API
Solution 1
You need to call it from a secure request https
and provide an access_token
:
https://graph.facebook.com/19292868552_118464504835613/comments?access_token=XXX
EDIT:
Added the object from the post
document. try clicking the comments
connection and then remove the access_token
and try and see the difference.
Solution 2
In order to get the Like
count and the comment
count then you need to use a combination of the PostOwnerID
and PostID
not just the PostID
So for your example it would be:
https://graph.facebook.com/153125724720582_184234384932460/comments
Again, as mentioned in some of the other answers you need to use the https
method along with an auth_token
Solution 3
I experienced the same problem with comments. The issue was that I was using an access token for a test user. Because test users don't have access to other FB users information, only the comments from pages were shown.
Solution 4
As a sanity check, do you have "read_stream" permission? I can see the full comments with my access token that uses "read_stream". As mentioned by other people, you have to use https and access token as well...
Solution 5
There is a word JUGAAR in Urdu that means, finding a way out, just to get the job done. So for like purpose I made this JUGAAR, I hope it helps.
$contents = file_get_contents("http://graph.facebook.com/" . $_GET['id'] . "/likes");
if (substr_count($contents, 'name')>0) {
echo substr_count($contents, 'name') . " people like this album";
}
By the way I am also new to this Fb stuff, I am looking for help to post comments. When I try to use graph.api./id/comments?access_token=sdfsfsdf&message="D" it still returns comments for the id instead of posting.
Related videos on Youtube
Jeaf Gilbert
Full-stack Developer (PHP, HTML, CSS, Javascript, MySQL)
Updated on August 07, 2020Comments
-
Jeaf Gilbert over 3 years
I tried to get Facebook comments using:
http://graph.facebook.com/[post_id]/comments
It results only 2 of 15 comments, and without
count
info.{ "data": [ { "id": "[post_id]", "from": { "name": "[name]", "id": "[id]" }, "message": "[message]", "created_time": "2011-01-23T02:36:23+0000" }, { "id": "[id]", "from": { "name": "[name]", "id": "[id]" }, "message": "[message]", "created_time": "2011-01-23T05:16:56+0000" } ] }
Anyone know why only 2 comments?
Also, I want to retrieve comments (default number) or retrieve comments with my limit number, and get its comments count. Any idea? (Please use Graph API).
-
Bartek almost 13 yearsHi Jeaffrey, could you please provide an example post with this behaviour? I checked several posts and the API always returns all comments. Make sure you provide proper
Post_ID
-
Harshal Kalavadiya over 9 years@JeaffreyGilbert how cani get Post_ID for getting comments for that pls. suggest me ,, i use same feature in my application
-
-
Jeaf Gilbert almost 13 yearsDoes access_token need fb app? I don't want people have to authorize my app first, except they want to put a comment. Am I in right direction?
-
ifaour almost 13 years@Jeafrey Gilbert: as long as they are commenting on something YOU own, then don't have to authorize your app or deal with it. You just need to be authorize...so the
access_token
is yours -
Enrico Susatyo almost 13 yearsno, you wouldn't know if it is something YOU own if you don't login. I think he needs to create an app ID and ask the user to login and authorize first.
-
Enrico Susatyo almost 13 yearsSorry I misread... If what YOU own is public, yes you can see it even if you're not authorized. But wouldn't you still need to be authorized to make any comments?
-
ifaour almost 13 years@the_great_monkey: 1)please don't down-vote before reading and understanding the problem. 2)even if what you own is public, depending what are the commenter privacy settings you may not be able to retrieve their comments without being authenticated.
-
Harshal Kalavadiya over 9 yearshow can i get 100002619172565_117323155031656 like id for getting all comments?
-
Harshal Kalavadiya over 9 yearshow can i get post_id for getting comments ,pls. suggest me!
-
mjs over 9 yearsYou get this in response of posting on user's wall using graph API
-
Ajay Takur over 9 years@HarshalKalavadiya Use this snippet to test in developement var body = 'Reading JS SDK documentation'; FB.api('/me/feed', 'post', { message: body }, function(response) { if (!response || response.error) { alert('Error occured'); } else { alert('Post ID: ' + response.id); } });
-
Ashok Singhal about 9 yearsHi, Thanks for the answer. I did use your code and got the comments and like of the posts. But, here is one of my concern. Where will i get the access_token as i am doing this reading comments and like from the website end. SO, I found a solution that the appid|app_secret will work as access_token . But here they arenot working. I also cant save the app generated access_token at server end. Because it will expire after 60 days as per facebook documentaion. Please suggest me. Thanks in advance
-
DMEM about 5 yearswhere can I get the
PostID
andPostOwnerID
from? -
DMEM about 5 years@ifaour I believe the
19292868552_118464504835613
represent theobject_id
. If that's the case, where can I get the object ID of my post?