Search code examples
facebookfacebook-graph-apifacebook-php-sdk

How to get likes count from facebook graph api which is shared from my web app?


I am able to get share count and comments count but unable to get the likes count. https://graph.facebook.com/?ids=MY_URL this API gives the response as,

{
  "MY_URL": {
     "share": {
        "comment_count": 0,
        "share_count": 13,
     },
     "id": "MY_URL",
  }
}

In the same way, I just need to get likes count/ reaction count from API. Please help. Thanks in Advance


Solution

  • Check out the engagement field - https://developers.facebook.com/docs/graph-api/reference/v3.2/url

    It returns four different counters - comment_count, comment_plugin_count, reaction_count and share_count.

    The reaction_count would be the number of all reactions (like, love, sad, …) - that is as much “detail” as you can get in this regard for external Open Graph objects.

    Example in Graph API Explorer, for the object http://example.com/:

    https://developers.facebook.com/tools/explorer?method=GET&path=%3Fids%3Dhttp%253A%252F%252Fexample.com%252F%26fields%3Dengagement&version=v3.2