skip to Main Content

I am wondering whether it is possible to obtain the reactions for all comments on a particular post? That is, for each comment on the post, can I also obtain the reactions in the current version of the API.

2

Answers


  1. It’s possible. Facebook Doc hasn’t updated yet. (I think.)

    But you can use “reactions” keyword with comment’s objects.

    Try this code with your sample Comment’s ID and Token.

    https://graph.facebook.com/v2.10/{comment_id}/reactions?access_token={Your_Token}
    

    Replace {comment_id} and {Your_Token} by your Comment’s ID and Token.

    For all comments of post, you can use the same with Post’ ID. See syntax on Facebook Doc

    Login or Signup to reply.
  2. So if you need a raw count, you can simply add reactions to the fields.

    For example:

    https://graph.facebook.com/v2.10/{post_id}/comments?fields=reactions.limit(0).summary(1)
    

    Then you can iterate over all comment and they have the reaction count included. Because you need the counts of the different types you can use the field aliasing. This looks like:

    "https://graph.facebook.com/v2.10/{post_id}/comments?fields=reactions.limit(0).summary(1)" // reactions overview
        + ",reactions.type(LIKE).limit(0).summary(1).as(reactions_like)" // like reactions
        + ",reactions.type(LOVE).limit(0).summary(1).as(reactions_love)" // love reactions
        + ",reactions.type(WOW).limit(0).summary(1).as(reactions_wow)" // wow reactions
        + ",reactions.type(HAHA).limit(0).summary(1).as(reactions_haha)" // haha reactions
        + ",reactions.type(SAD).limit(0).summary(1).as(reactions_sad)" // sad reactions
        + ",reactions.type(ANGRY).limit(0).summary(1).as(reactions_angry)" // angry reactions
        + ",reactions.type(THANKFUL).limit(0).summary(1).as(reactions_thankful)" // thankful reactions
    

    I used a String concatenation to provide a better overview. You have to adapt this to your language.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search