Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting like and comment counts per post of facebook page by graph api version 2

I have been getting like and comment counts per post of facebook page/group feed call by graph api separately using FQL but as version 2 of graph api released fql no longer working to serve purpose.

So i have to find new ways to get comment and like counts per post of page feed display. I will make a separate call to get comment and like counts per post of the fb page as it may not be possible to get things in same page feed call(or it is?).

So, searching through google, i found following way using graph api call -

..page_id/feed?fields=likes.limit(1).summary(true){id},comments.limit(1).summary(true)&limit=10

Is this the best and error free way?? Also besides id and summary fields i also get created_time, paging, likes data by the above call which is unexpected and redundant, how do i exclude these additional fields?

So please any FB employee show me light on what is the best way to retrieve like and comment count per post of page/group feed using graph api version 2.

like image 409
dev-m Avatar asked Aug 15 '14 15:08

dev-m


People also ask

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?

Applies to all versions. Facebook Analytics will no longer be available after June 30, 2021. Additionally, we are deprecating the App Dashboard Plugin for Marketing API. For more information visit the Business Help Center.

How do I use Facebook Graph API and extract data?

To use the Graph API Explorer tool, go to developers.facebook.com/tools/explorer. Generate the access token you need to extract data from the Facebook Graph API by selecting Get User Access Token from the App Token drop-down menu under the name of your app.

What 3 terms does Facebook use to describe what the graph API is composed of?

The Graph API is named after the idea of a "social graph" — a representation of the information on Facebook. It's composed of nodes, edges, and fields.


1 Answers

If you want to retrieve Likes and comments count of a post on FB you can achieve this by using Id of the post Like this

..Your_Post_ID?fields=likes.limit(0).summary(true),comments.limit(0).summary(true)

the result will contain Total numbers of likes of the post, total numbers of comments of the post, post ID and post created time.

The result will be like this

{
  "likes": {
    "data": [
    ], 
  "summary": {
    "total_count": 550
   }
  }, 
  "comments": {
    "data": [
    ], 
    "summary": {
    "order": "chronological", 
    "total_count": 858
    }
  }, 
  "created_time": "2014-10-12T05:38:48+0000", 
  "id": "Your_Post_ID"
}
like image 100
Akshay Khale Avatar answered Oct 31 '22 12:10

Akshay Khale