Skip to content

Instantly share code, notes, and snippets.

@abass
Created January 22, 2014 06:19
Show Gist options
  • Save abass/8554232 to your computer and use it in GitHub Desktop.
Save abass/8554232 to your computer and use it in GitHub Desktop.
function facebook_shares($url){
$fql = "SELECT url, normalized_url, share_count, like_count, comment_count, ";
$fql .= "total_count, commentsbox_count, comments_fbid, click_count FROM ";
$fql .= "link_stat WHERE url = '".$url."'";
$apifql="https://api.facebook.com/method/fql.query?format=json&query=".urlencode($fql);
$fb_json=file_get_contents($apifql);
return json_decode($fb_json);
}
$fb = facebook_shares('https://www.facebook.com/redbull');
// facebook share count
echo $fb[0]->share_count;
// facebook like count
echo $fb[0]->like_count;
// facebook comment count
echo $fb[0]->comment_count;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment