Getting Facebook Reactions with Graph API

后端 未结 7 1938
你的背包
你的背包 2020-12-23 20:47

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

相关标签:
7条回答
  • 2020-12-23 21:38

    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"
    }
    
    0 讨论(0)
提交回复
热议问题