Reputation: 11
I want to integrate the facebook 'like' button onto my website and I have done this successfully. I have multiple articles in a single web page and under each article a 'like' button is added. Now I want to retrieve the number of likes for each button in a different webpage. Is it possible to specify an id when declaring the 'like' button and then using this same id to retrieve the number of clicks from facebook. Could someone explain to me as to how this works? Please provide a code example if possible.
Thanks
Upvotes: 1
Views: 171
Reputation: 66
You can use the FQL to ask for the like count
in your code you can use something like this:
$query='SELECT normalized_url,comment_count,like_count,total_count FROM link_stat WHERE url IN ("http://yourwebsite.com/articles/1","http://yourwebsite.com/articles/2")';
$url = "http://graph.facebook.com/fql?q=".urlencode($query);
$data = json_decode(file_get_contents($url),true); //better use curl
and you have and array with the comments_count and likes_counts from your urls, example:
FQL for facebook.com and google.com stats
REFERENCES
https://developers.facebook.com/docs/reference/fql/link_stat/
Upvotes: 1
Reputation: 3966
Read Facebook for Websites, it tells you everything about using the like plugin in your website.
Upvotes: 0