Replace the $page_id value with your Page ID number (unless you want to show the number of fans for this site).You can find your Page ID by logging into your Facebook account, going to 'Adverts and Pages', clicking 'Edit page', and looking at the URL.
For example, mine is https://www.facebook.com/pages/edit/?id=143394365692197&sk=basic.
I've also wrapped the output in a number_format() function so that it properly formatted with commas etc - like where I've used it within the Gold Event listing on the Horse & Country TV website.
{syntaxhighlighter brush: css;fontsize: 100; first-line: 1; }<?php
$page_id = "143394365692197";
$xml = @simplexml_load_file("http://api.facebook.com/restserver.php?method=facebook.fql.query&query=S...".$page_id."") or die ("a lot");
$fans = $xml->page->fan_count;
print number_format($fans);
?>{/syntaxhighlighter}
This code was originally found on wp-snippets.com.
Comments
Thank you so much for this.
Thank you so much for this. Googled this and it brought me here. My page now shows how many fans I have on FB! Amazing, thank you again :)
Alice @ http://thejojobaoil.com/
No problem! I'm glad that you
No problem!
I'm glad that you found it useful.
Thanks,
Oliver
Awesome! Till the very end i
Awesome! Till the very end i couldnt believe this is possible! I'm very grateful you brought this article here.
Nice, thank you for the tips
Nice, thank you for the tips !
Sylvain from France
Thank you so much for this.
Thank you so much for this. Googled this and it brought me here. Thanks Again!
Dave @ www.fourgltephones.com
Good Work ! I'm very grateful
Good Work ! I'm very grateful you brought this article here. Thanks
Thank you so much for this.
Thank you so much for this. Googled this and it brought me here. Thanks Again!
Add new comment