|
Facebook Like and Share count can easily be obtained from the Facebook Graph API. This is an extremely quick way to look up the JSON response from Facebook so that you can further process it for your own requirements.
$URL =’https://graph.facebook.com/cocacola’;
$JSON = file_get_contents($URL);
$Output = json_decode($JSON);
$Likes = 0;
if($Output->likes){
$Likes = $Output->likes;
}
echo “Number of likes for CocaCola’s Facebook Page = “.$Likes.”</br>”;
$URL2 =’https://graph.facebook.com/http://www.coca-cola.com’;
$JSON2 = file_get_contents($URL2);
$Output2 = json_decode($JSON2);
$Shares = 0;
if($Output2->shares){
$Shares = $Output2->shares;
}
echo “Number of shares for coca-cola.com = “.$Shares;
?>
UPDATE 29/01/2012: I’ve written a slightly different method using the PHP SDK in this post here



| Based on a theme by Ori Pearl