Another, simpler way to display facebook fan count as text
March 25th, 2012 - 7 Comments »
I can now show you a much simpler way to display your Facebook fan count as text on your website. It is alot simpler than the previous way, although it is entirely up to you how you wish to display it.
Step 1 – Find out your Facebook pages ID
Page ID is the ID of your Facebook Fan Page. If you don’t have a Facebook Fan page, you’ll have to first create one. To get the ID of your Fan page, click edit page, and look for your ID (numbers) at the end of the URL – eg: http://www.facebook.com/pages/edit/?id=XXXXXXXXX
Step 2 – Copy and Paste
Copy and paste the code below anywhere within your website where you would like the Fan count to show. Remember to change the “XXXXXXXXXXXX” to your Facebook Pages ID.
$page_id = "XXXXXXXXXXXX";
$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;
There you have it, a much simpler way of displaying your fan count!