Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting Facebook Post all Reactions Count in single Graph API request

As Facebook released the new reaction{NONE, LIKE, LOVE, WOW, HAHA, SAD, ANGRY} feature for post, but I can not figure out to get all reaction counts in single graph API request.

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

like image 582
KabirB Avatar asked Apr 28 '16 06:04

KabirB


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.

How do I get data from Facebook Graph API?

From “Graph API Explorer” drop down, select your app. Then, select “Get Token”. From this drop down, select “Get User Access Token”. Select permissions from the menu that appears and then select “Get Access Token.”


2 Answers

The approach introduced by @CBroe appears to be working using Multiple ID Read Requests.

?ids=7175346442_10153799389241443,7175346442_10153799470326443&fields=reactions.type(LOVE).limit(0).summary(total_count).as(reactions_love),reactions.type(WOW).limit(0).summary(total_count).as(reactions_wow),reactions.type(HAHA).limit(0).summary(total_count).as(reactions_haha),...

Screenshot from Facebook Graph API Explorer:

enter image description here

Once a collection of posts is retrieved, one should be able to read reaction counts grouped by type using a single request. Note, the current limit of ids in the Multiple ID Read Request pattern is 50.

like image 119
Anthony Battaglia Avatar answered Sep 20 '22 23:09

Anthony Battaglia


Theoretically possible using Field Expansion in combination with Field Aliases, like this:

?fields=reactions.type(LIKE).limit(0).summary(1).as(like),
        reactions.type(WOW).limit(0).summary(1).as(wow),
        reactions.type(SAD).limit(0).summary(1).as(sad),…

But there still seem to be some bugs in that regard; I frequently got “An unknown error has occurred” while testing this; f.e. replacing the limit value for LIKE with 1 in the above query triggers it …

like image 40
CBroe Avatar answered Sep 23 '22 23:09

CBroe