如何获得Facebook喜欢的数量

How to get facebook likes count

我试过这段代码:

 FB.api('/facebook/feed?fields=message,likes',   function(response) {
    document.getElementById("content").innerHTML += response.data[0].likes.count;
 });

但我得到 'undefined' 作为值。

没有likes.count属性。下次请看看文档...您需要使用

/facebook/feed?fields=message,likes.summary(true).limit(0)

作为查询。您可以在 Graph Explorer which return

中尝试此操作
{
  "data": [
    {
      "message": "2015 brought us triumph, tragedy, heartbreak and hope. Here's to all the connections we've made this year, and all the ones we'll make in the next.",
      "id": "20531316728_10154249775416729",
      "likes": {
        "data": [
        ],
        "summary": {
          "total_count": 295795,
          "can_like": true,
          "has_liked": false
        }
      }
    }
  ],
  "paging": {
    "previous": "https://graph.facebook.com/v2.5/20531316728/feed?fields=message,likes.summary%28true%29.limit%280%29&limit=1&format=json&since=1450030400&access_token=&__paging_token=&__previous=1",
    "next": "https://graph.facebook.com/v2.5/20531316728/feed?fields=message,likes.summary%28true%29.limit%280%29&limit=1&format=json&access_token=&until=1450030400&__paging_token="
  }
}

示例:

FB.api('/facebook/feed?fields=message,likes.summary(true).limit(0)',   function(response) {
    document.getElementById("content").innerHTML += response.data[0].likes.summary.total_count;
});