Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Shaz3e/15e06d20d225f79756a8 to your computer and use it in GitHub Desktop.
Save Shaz3e/15e06d20d225f79756a8 to your computer and use it in GitHub Desktop.
Display number of Facebook fans in full text
If you have a Facebook page for your website or blog, you might want to display how many fans you have. This snippet will help you to get your Facebook fan count, in full text. Don’t forget to add your page ID on line 2.
<?php
$page_id = "YOUR PAGE-ID";
$xml = @simplexml_load_file("http://api.facebook.com/restserver.php?method=facebook.fql.query&query=SELECT%20fan_count%20FROM%20page%20WHERE%20page_id=".$page_id."") or die ("a lot");
$fans = $xml->page->fan_count;
echo $fans;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment