How to retrieve number of likes from Facebook Like Button code

I need to check with PHP how many likes is showing in Facebook Like Button.

For some reasons I can't just perform a FQL query to get number of likes. I have to operate on a FB Like Button html/js code.

Example:

<div id="fb-root"></div>
<script>(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) return;
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/en_GB/all.js#xfbml=1";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>

<fb:like href="http://www.example.com" send="false" width="450" show_faces="false"></fb:like>

I really don't want to install and use some JS interpreter to retrive Likes value. Is there a simpler way to do it?

Answers


You can get the number of likes using FQL. For example, I created this like button using the Like Button plugin creator tool:

<fb:like href="http://plooza.com" send="false" width="450" show_faces="true"></fb:like>

Then I can get the number of likes using FQL, using the Graph API Explorer as a quick test:

SELECT url, normalized_url, share_count, like_count, comment_count, total_count, commentsbox_count, comments_fbid, click_count FROM link_stat WHERE url="plooza.com"

The output was:

{
  "data": [
    {
      "url": "plooza.com", 
      "normalized_url": "http://www.plooza.com/", 
      "share_count": 0, 
      "like_count": 2, 
      "comment_count": 0, 
      "total_count": 2, 
      "commentsbox_count": 0, 
      "comments_fbid": "1015079258276xxxx", 
      "click_count": 0
    }
  ]
}

Need Your Help

Make a AJAX HTTPS POST Request with parameters in header

c# ajax asp.net-mvc

I am using asp.net MVC and I would like to make a https post request with ajax (with the parameters in the header) to a method in my controller. By now I did a get http with the parameters in the u...

Where can I get the update site for Spring tool suite

eclipse spring eclipse-plugin spring-tool-suite

Actually I am trying to install spring tool suit for eclipse Kepler(4.3) from eclipse marketplace but I am getting the following error