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?

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:

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.


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 …


Simply use the following as part of your graph query

fbpageid/posts?fields=created_time,story,message,shares,reactions.type(LIKE).limit(0).summary(1).as(like),reactions.type(LOVE).limit(0).summary(1).as(love),reactions.type(HAHA).limit(0).summary(1).as(haha),reactions.type(WOW).limit(0).summary(1).as(wow),reactions.type(SAD).limit(0).summary(1).as(sad),reactions.type(ANGRY).limit(0).summary(1).as(angry)&limit=10

So I'll be getting Post ID, Created time, Story, Message, Share Count, reaction count (currently 6 reaction) using only 1 query. It works with APi v2.9 as well


If you have read_insights permission, you could get reactions in following way for feed or a post

fields=insights.metric(post_reactions_by_type_total).period(lifetime).as(post_reactions_by_type_total)

and you would get results like:

        "name": "post_reactions_by_type_total",
        "period": "lifetime",
        "values": [
          {
            "value": {
              "like": 10,
              "love": 2,
              "wow": 3,
              "haha": 1,
              "sorry": 1,
              "anger": 2
            }
          }
        ],

I found a way to achieve this with 1 request:

GET /{userId}?fields=
  posts.as(like){reactions.type(LIKE).limit(0).summary(true)},
  posts.as(love){reactions.type(LOVE).limit(0).summary(true)},
  posts.as(wow){reactions.type(WOW).limit(0).summary(true)},
  posts.as(haha){reactions.type(HAHA).limit(0).summary(true)},
  posts.as(sad){reactions.type(SAD).limit(0).summary(true)},
  posts.as(angry){reactions.type(ANGRY).limit(0).summary(true)},
  posts.as(thankful){reactions.type(THANKFUL).limit(0).summary(true)}

This way you will receive 7 lists of posts (one per each reaction). Example:

{
  "like": {
    "data": [<list of posts>]
  },
  "love": {
    "data": [<list of posts>]
  },
  "wow": {
    "data": [<list of posts>]
  },
  "haha": {
    "data": [<list of posts>]
  },
  "sad": {
    "data": [<list of posts>]
  },
  "angry": {
    "data": [<list of posts>]
  },
  "thankful": {
    "data": [<list of posts>]
  },
  "paging": {
    "previous": "...",
    "next": "..."
  },
  "id": "<userId>"
}

Need Your Help

Inserting new row in sql database table

c# .net sql insert

I have textBoxes in my application. The data entered in those textBoxes are to be inserted in the database. The commandString accepts string type only. So, how can I implement the insert statement?

undefined method `simple_form_for' in RoR application

ruby-on-rails ruby-on-rails-3 simple-form

I've been browsing stack overflow and I noticed that many people use simple_form to make their lives easier.