Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

facebook graph API endpoint for getting "likes, shares, comments" for post(s)

Tags:

Facebook is planning to drop support for FQL after V2.0 https://developers.facebook.com/docs/apps/changelog/#v2_0_fql

The below task could be done easily with FQL

SELECT like_info.like_count, comment_info.comment_count, share_count  FROM stream  WHERE post_id = "POST_ID_HERE" 

I am unable to find a replacement to the above method in graph api. I know we can get likes and comments count like

POST_ID/likes?summary=true AND  POST_ID/comments?summary=true  

but I am unable to find a similar endpoint for shares.

NOTE: I am not looking for solutions that take URL input and query graph api for that URL shares, rather I am looking at finding solution to get shares count by POST_ID

PAGE_ID/feed?fields=comments.limit(1).summary(true),likes.limit(1).summary(true) 

I have looked at.

  1. Facebook API: best way to get like, share, comment count for a page/group post?
  2. How to get Likes Count when searching Facebook Graph API with search=xxx
  3. Facebook post comment count from Graph API
  4. http://www.quora.com/Facebook-Graph-API/Facebook-Graph-API-How-to-get-the-number-of-likes-on-a-status

The result should be something like this:

{   "data": [{       "like_info": {       "like_count": 3506     },        "comment_info": {       "comment_count": 263     },        "share_count": 278   }] } 

Any help would be highly appreciated.

Cheers!

UPDATE: It was an access token issue as the token I was using did not have "read_stream" permission.

like image 775
Jaspal Singh Avatar asked May 25 '14 20:05

Jaspal Singh


People also ask

What data can I get from Facebook Graph API?

The Graph API is the primary way to get data into and out of the Facebook platform. It's an HTTP-based API that apps can use to programmatically query data, post new stories, manage ads, upload photos, and perform a wide variety of other tasks.

How do I get Facebook Page Insights on graph API?

You can access Page Insights by typing /insights after the name of your page in the URL field. This command will retrieve all of the Insights associated with your Page. Type "/insights" after your company name. Click the Submit button.

Is Facebook Graph API deprecated?

API Version Deprecations: As part of Facebook's Graph API and Marketing API, please note the upcoming deprecations: August 3, 2021: Graph API v3. 3 will be deprecated and removed from the platform. August 25, 2021 Marketing API v9.


2 Answers

The field shares does not need the .summary(true) at the end. It will bring always the total. But the likes and comments does need .summary(true)

Example:

[POST_ID]?fields=shares,likes.summary(true),comments.summary(true)

Improved version works with Graph Api v2.11 (add limit(0) to removes lists of likes and comments and get only summary data):

[POST_ID]?fields=shares,likes.summary(true).limit(0),comments.summary(true).limit(0)

This will bring the total count of shares, comments and likes.

You may have a access_token with an read_stream permission to get the shares count.

like image 75
João Mosmann Avatar answered Oct 27 '22 01:10

João Mosmann


Get likes, comments and shares and all 3 combined.

Check my ans : https://stackoverflow.com/a/36997725/2439715

Improved version ( add limit(0) to removes list of likes and get only summary ):

114916098537132_1265715836790480?fields=shares,likes.limit(0).summary(true),comments.limit(0).summary(true) 
like image 39
Abhishek Goel Avatar answered Oct 26 '22 23:10

Abhishek Goel