Get number of likes of your/any Facebook page via PHP

If you want to use somewhere the number of people who likes your fan page, here’s the way to do that:

Create
Create a new basic application from here. Just enter some data and you will receive AppID and Secret keys.

Download
Download the PHP library to work with Facebook API.

git clone https://github.com/facebook/php-sdk.git

Write

require('php-sdk/src/facebook.php');
$facebook = new Facebook(array(
	'appId' => '000000000', // put appID here - see Create section
	'secret' => '0000c000c000c000c', //put your secret key here - see Create section
	));
$zt = $facebook->api('/ZeroTurnaround'); // my Facebook page is http://www.facebook.com/ZeroTurnaround
echo $zt['likes'];

Done

Bogomil Shopov

Bogo is a marketing person addicted to the Internet and its power. Before he was mentioned in Wikileaks and Forbes (twice) he was a nice person. Now he is a marketer :) He loves beers, traveling and his family a lot. Monty Python and Metal music fan.

One thought on “Get number of likes of your/any Facebook page via PHP

  1. What if i have to get the number of like from a page that is not on Facebook.

    For eg. I have a like button for a page on my website and i want to grab the number of likes of that page. How can that be done?

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">