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

Posted January 24th, 2012 in Closed Technologies by Bogo

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

Quick short URL PHP function

Posted August 27th, 2010 in Open Technologies by Bogo
1
2
3
4
5
function shortURL($long)
{
 $short=file_get_contents("http://is.gd/api.php?longurl=".$long);
 return $short;
}

Usage:

1
2
$short = shortURL("http://veryveryveryverylongurl.tld/something/verylong.php");
echo $short;