使用Graph API获取Facebook反应

lar*_*ter 31 facebook facebook-graph-api

Facebook刚刚发布了新的反应按钮,但我无法找到从Graph API v2.5获取此信息的方法,因为/ likes边缘仅返回交互的总数.

有没有人想出办法让每个帖子得到这个详细的反应?

rya*_*yer 11

编辑:截至2016年4月12日,Facebook发布了帖子的反应终点,作为他们的GraphAPI v2.6版本的一部分

GET /v2.6/{object-id}/reactions

更多信息可以在这里找到:https://developers.facebook.com/docs/graph-api/reference/post/reactions

结束编辑

我不确定Facebook是否已发布此信息,但反应信息目前在Graph API v2.5中提供.我粘贴了下面的回复.我通过点击洞察端点实现了这个结果.对于下面的响应中列出的每个对象,请查看"id"属性,它具有更精细的查询端点.

GET /v2.5/{object-id}/insights
Run Code Online (Sandbox Code Playgroud)

响应:

   {
  "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"
}
Run Code Online (Sandbox Code Playgroud)


cod*_*ami 6

Facebook刚刚发布了Graph API 2.6,反应端点也是如此

GET /v2.6/{object-id}/reactions
Run Code Online (Sandbox Code Playgroud)

返回了类似的东西

{
  "data": [
    {
      "id": "ACCOUNT-ID",
      "name": "ACCOUNT-NAME",
      "type": "HAHA"
    },
    {
      "id": "ACCOUNT-ID",
      "name": "ACCOUNT-NAME",
      "type": "LIKE"
    }
  ],
  "paging": {
    "cursors": {
      "before": "TkRZAMU9EWTROakF6TmpBM01qYzJPak2TnpnNE5qUTRNRE0zT1RFek16RXkZD",
      "after": "TVRBd01EQTNOekEwTWpnME1EUTJPakUwTazJNVFl4TXc9PQZDZD"
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

更多信息:https://developers.facebook.com/docs/graph-api/reference/post/reactions/


小智 6

尝试

GET /v2.5/{post_id}/insights/post_reactions_by_type_total
Run Code Online (Sandbox Code Playgroud)

哪个返回

{
 "data": [
  {
     "name": "post_reactions_by_type_total",
     "period": "lifetime",
     "values": [
        {
           "value": {
              "like": 9,
              "love": 0,
              "wow": 1,
              "haha": 0,
              "sorry": 0,
              "anger": 0
           }
        }
     ],
     "title": "Daily total post reactions by type.",
     "description": "Daily total post reactions by type.",
     "id": "{post_id}/insights/post_reactions_by_type_total/lifetime"
   }
 ],
}
Run Code Online (Sandbox Code Playgroud)

我在 Facebook Graph API 2.3 中使用了相同的方法,但并不是对每个请求都幸运