Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to retrieve all post comments/likes via Facebook OpenGraph

Tags:

I am trying to retrieve comments and likes for specific posts through Facebook's opengraph API. While I do get some information back, it does not always match the comments/likes count mentioned in the post. I guess this can be attributed to the access permissions of the token I'm using. However, I have noticed that results vary depending on the request limit I use, and sometimes I also get duplicate entries between requests.

For example, post 10376464573_150423345118848 has about 14000 likes as of this writing, but I can only retrieve a maximum of around 5000. With the default limit of 25 I can get up to 3021 likes. A value of 100 gives 4501, while limits of 1000, 2000, 3000 and 5000 all return the same number of likes, 4959 (the absolute values don't make too much sense of course, they are just there for comparison).

I have noticed similar results on a smaller scale for comments.

I'm using a simple python script to fetch pages. It goes through the data following the pagination links provided by Facebook, writing each page retrieved to a separate file. Once an empty reply is encountered it stops.

With small limits (e.g. the default of 25), I notice that the number of results returned is monotically decreasing as I go through the pagination links, which seems really odd.

Any thoughts on what could be causing this behavior and how to work around it?

like image 945
mpitid Avatar asked Mar 25 '13 18:03

mpitid


People also ask

Is there a way to view all previous comments on Facebook?

Tap in the top right of Facebook, then tap your name. Tap below your profile picture, then tap Activity Log. Tap Filter at the top of your activity log to review activities like: Things you've posted.

How do I find my comments and likes on Facebook?

To get there, tap your name in the blue stripe at the top of any Facebook page. Once you've reached your profile, click the View Activity Log button to the right of your profile image. To filter your log so you're only seeing the stuff you liked, click the Likes button in the left column of the screen.

How can I See comments made on a post on Facebook?

once you go to Activity Log" then to "Comments" Click on it then scroll down until you see your "Post you comment on" then click on it and it will pull up all the comments on that post, you will then see if there was any new comments on it. ... Thanks. Originally Answered: How can you see comments made on Facebook?

How to view your own posts and likes on Facebook?

If you want to view your own posts, likes by you on the posts, comments made by you, etc. then for this just follow below steps 3 Click on the Setting icon. 4a. Click on Page likes button to get all like made by you 4b. Click on the following button to get all you have followed

Why can’t I reply back to comments on my Facebook posts?

The only way you may not be able to Reply Back to the Comments is if Facebook Issued a Temporary Comment Block If that is the Situation you may have to Wait til the Block is Lifted Before you can Reply back to Comments on your Posts Why are comments on public posts on Facebook not always visible?

Why do my comments appear above or below my posts on Facebook?

A common reason is that the comments are just being prioritized to show relevant comments first. Here’s what Facebook says: When you see above the comments in a Page post, it means that you're more likely to see comments that are relevant to you. This means that you're more likely to see the following at the top:


1 Answers

If you are looking for a list of the names of each and every like / comment on a particular post I think you will run up against the API limit (even with pagination).

If you are merely looking for an aggregate number of likes, comments, shares, or link clicks, you'll want to simply use the summary=true param provided in the posts endpoint. Kind of like this:

try:
    endpoint = 'https://graph.facebook.com/v2.5/'+postid+'/comments?summary=true&access_token='+apikey
    response = requests.get(endpoint)
    fb_data = response.json()
    return fb_data

You can also retrieve all of the posts of any particular page and their summary data points:

{page_id}/posts?fields=message,likes.limit(1).summary(true)
like image 191
Mike Portanova Avatar answered Oct 11 '22 07:10

Mike Portanova