Skip to content

Instantly share code, notes, and snippets.

@Uriel29
Created November 20, 2014 16:25
Show Gist options
  • Save Uriel29/c58fb6f9d8b55267511d to your computer and use it in GitHub Desktop.
Save Uriel29/c58fb6f9d8b55267511d to your computer and use it in GitHub Desktop.
Get likes facebook page URL
<?php
function get_fb_likes($url)
{
$query = "select total_count,like_count,comment_count,share_count,click_count from link_stat where url='{$url}'";
$call = "https://api.facebook.com/method/fql.query?query=" . rawurlencode($query) . "&format=json";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $call);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec($ch);
curl_close($ch);
return json_decode($output);
}
$fb_likes = reset( get_fb_likes("http://oceanoliterario.com/indicacoes/88-stanix-o-poder-dos-elementos-eder-a-s-traskini") ); //URL
echo $fb_likes->total_count;
echo $fb_likes->like_count;
echo $fb_likes->comment_count;
echo $fb_likes->share_count;
echo $fb_likes->click_count;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment