user1105951
user1105951

Reputation: 2287

Get Facebook reactions total_count for each type of reaction

In Graph Api 2.6 with the new Reactions edge, Is there way to get the summary that include total_count for each reaction ?

I mean, something like this :

"summary": {
      "total_count": 51,
      "total_count_HAHA":23,
      "total_count_LOVE":28,
      "viewer_reaction": "NONE"
    }

there is only "total_count" right now.

Upvotes: 8

Views: 6078

Answers (4)

reactions.type(HEART).summary(totalCount)

Upvotes: 0

cacheoff
cacheoff

Reputation: 299

You can use nested request.

request url should be like

https://graph.facebook.com/{id}?fields=reactions.type({reactiontype})[,reactions.type({reactiontype})] 

If you want to get total count of each reaction then you can add summary(total_count) end of each request.

An example

reations.type(LIKE).summary(totalCount)

If you want to limit data you can use limit keyword as well.

reactions.type(LIKE).limit(0).summary(totalCount)

And finally you can rename response node using "as" keyword

reactions.type(LIKE).limit(0).summary(totalCount).as(like_count)

A sample usage and response

Request Url https://graph.facebook.com/1230378837038354?fields=reactions.type(LIKE).limit(0).summary(total_count).as(like),reactions.type(LOVE).limit(0).summary(true).as(love)&access_token=

Response

{
   "like": {
      "data": [

      ],
      "summary": {
         "total_count": 342
      }
   },
   "love": {
      "data": [

      ],
      "summary": {
         "total_count": 165,
         "viewer_reaction": "NONE"
      }
   },
   "id": "1230378837038354"
}

Upvotes: 0

David Beneš
David Beneš

Reputation: 389

20531316728_10154835146021729?fields=
    reactions.type(LIKE).summary(total_count).limit(0).as(like),
    reactions.type(LOVE).summary(total_count).limit(0).as(love),
    reactions.type(WOW).summary(total_count).limit(0).as(wow),
    reactions.type(HAHA).summary(total_count).limit(0).as(haha),
    reactions.type(SAD).summary(total_count).limit(0).as(sad),
    reactions.type(ANGRY).summary(total_count).limit(0).as(angry)

Upvotes: 18

QuotidianVoid
QuotidianVoid

Reputation: 619

The only thing I can think of is to make multiple API calls for each reaction type... If you limit your reactions to type=HAHA, the total_count will only count HAHAs. Certainly not the most efficient approach, but workable depending on what you are trying to accomplish...

Upvotes: 1

Related Questions