21

How to get number of likes from facebook like button? Is there any possible way to do this?

bkaid
  • 51,465
  • 22
  • 112
  • 128
ivan_jovan
  • 261
  • 1
  • 3
  • 5

1 Answers1

26

There are two ways to get the number of facebook likes.

  1. Graph API

http://graph.facebook.com/?ids=http%3a%2f%2ffacebook.com

Result is JSON: (For some reason 'likes' are called 'shares')

{
   "http://facebook.com": {
      "id": "http://facebook.com",
      "shares": 35641554,
      "comments": 339
   }
}
  1. FQL

http://api.facebook.com/method/fql.query?query=select+total_count+from+link_stat+where+url="http://facebook.com"'

Result:

<?xml version="1.0" encoding="UTF-8"?>
<fql_query_response xmlns="http://api.facebook.com/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" list="true">
  <link_stat>
    <total_count>35641554</total_count>
  </link_stat>
</fql_query_response>
sakibmoon
  • 2,026
  • 3
  • 22
  • 32
Jason Moore
  • 7,169
  • 1
  • 44
  • 45
  • Reason this called shares is probably cause of statements on [Like Button documentation](http://developers.facebook.com/docs/reference/plugins/like/), read **What makes up the number shown on my Like button?** section – Juicy Scripter Oct 15 '11 at 19:32
  • 1
    Do you know the limit/ the number of links you can get stats of in only one request? I need this information in my design but cannot find it in the documentation. Thanks a lot. – Damien Jun 22 '12 at 08:38
  • FQL won't be available anymore from August 2016: https://developers.facebook.com/docs/reference/fql/ – mm24 Jul 26 '16 at 15:57