Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting Facebook Reactions with Graph API

Facebook just released the new reaction button, but I can't figure out a way to get this information from the Graph API v2.5 as the /likes edge only returns the total count of interactions.

Has anyone figured out a way to get this detailed reactions per post?

like image 986
larrydahooster Avatar asked Feb 24 '16 15:02

larrydahooster


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.

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.

Does Facebook use graph API?

The Graph API is the primary way for apps to read and write to the Facebook social graph. All of our SDKs and products interact with the Graph API in some way, and our other APIs are extensions of the Graph API, so understanding how the Graph API works is crucial.


2 Answers

EDIT: As of April 12th, 2016 Facebook has published a reactions endpoint for posts as part of their v2.6 release of the GraphAPI

GET /v2.6/{object-id}/reactions

More information can be found here: https://developers.facebook.com/docs/graph-api/reference/post/reactions

END EDIT

I'm not sure if Facebook has published this yet, but the reaction information is currently available in the Graph API v2.5. I pasted the response below. I achieved this result by hitting the insights endpoint. For each object listed in the response below, take a look at the 'id' property, it has more granular query endpoints.

GET /v2.5/{object-id}/insights 

RESPONSE:

   {   "name": "post_reactions_like_total",   "period": "lifetime",   "values": [     {       "value": 0     }   ],   "title": "Lifetime Like Reactions",   "description": "Lifetime: The total number of like reactions to your post.",   "id": "{node_id}/insights/post_reactions_like_total/lifetime" }, {   "name": "post_reactions_love_total",   "period": "lifetime",   "values": [     {       "value": 0     }   ],   "title": "Lifetime Love Reactions",   "description": "Lifetime: The total number of love reactions to your post.",   "id": "{node_id}/insights/post_reactions_love_total/lifetime" }, {   "name": "post_reactions_wow_total",   "period": "lifetime",   "values": [     {       "value": 0     }   ],   "title": "Lifetime Wow Reactions",   "description": "Lifetime: The total number of wow reactions to your post.",   "id": "{node_id}/insights/post_reactions_wow_total/lifetime" }, {   "name": "post_reactions_haha_total",   "period": "lifetime",   "values": [     {       "value": 0     }   ],   "title": "Lifetime Haha Reactions",   "description": "Lifetime: The total number of haha reactions to your post.",   "id": "{node_id}/insights/post_reactions_haha_total/lifetime" }, {   "name": "post_reactions_sorry_total",   "period": "lifetime",   "values": [     {       "value": 0     }   ],   "title": "Lifetime Sorry Reactions",   "description": "Lifetime: The total number of sorry reactions to your post.",   "id": "{node_id}/insights/post_reactions_sorry_total/lifetime" }, {   "name": "post_reactions_anger_total",   "period": "lifetime",   "values": [     {       "value": 0     }   ],   "title": "Lifetime Anger Reactions",   "description": "Lifetime: The total number of anger reactions to your post.",   "id": "{node_id}/insights/post_reactions_anger_total/lifetime" }, {   "name": "post_reactions_by_type_total",   "period": "lifetime",   "values": [     {       "value": {         "like": 0,         "love": 0,         "wow": 0,         "haha": 0,         "sorry": 0,         "anger": 0       }     }   ],   "title": "Lifetime Reactions by type",   "description": "Lifetime: The total number of reactions to your post by type.",   "id": "{node_id}/insights/post_reactions_by_type_total/lifetime" } 
like image 81
ryankdwyer Avatar answered Sep 30 '22 21:09

ryankdwyer


Facebook just released Graph API 2.6 and the reaction endpoint is available like so

GET /v2.6/{object-id}/reactions 

Which returned something like

{   "data": [     {       "id": "ACCOUNT-ID",       "name": "ACCOUNT-NAME",       "type": "HAHA"     },     {       "id": "ACCOUNT-ID",       "name": "ACCOUNT-NAME",       "type": "LIKE"     }   ],   "paging": {     "cursors": {       "before": "TkRZAMU9EWTROakF6TmpBM01qYzJPak2TnpnNE5qUTRNRE0zT1RFek16RXkZD",       "after": "TVRBd01EQTNOekEwTWpnME1EUTJPakUwTazJNVFl4TXc9PQZDZD"     }   } } 

More infos here : https://developers.facebook.com/docs/graph-api/reference/post/reactions/

like image 35
codeKonami Avatar answered Sep 30 '22 19:09

codeKonami