<?php
/**
+ Info: How to Use New Facebook API 2.8 for Fan Page
+ Email: [email protected]
+ Pastebin: http://pastebin.com/u/tero
**/
# The PHP Code
function fb_count($pageid) {
$fb_vs = 'v2.8'; // The most recent version of the API
// Important: You must have App ID and App Secret for this code to work.
// You have to replace these settings, they will not be available for long time.
$appid = '259036654457513';
$secret = '032ce70371267b1e80691ea0f59eb12c';
$fb_url = "https://graph.facebook.com/".$fb_vs."/".$pageid."?fields=fan_count&access_token=".$appid."|".$secret;
if (!empty($pageid)) {
$decode = json_decode(@file_get_contents($fb_url));
if (empty($decode->id))
$result = 'This facebook page id doesn\'t exist.'; // If the page doesn't exist or access token is not set.
else
$result = $decode->fan_count; // Here is the correct result
}
else {
$result = 'You need to provide a facebook page !'; // When is not set anything
}
return $result;
}
# How to use
/*
You can use three options (Example):
URL: http://facebook.com/eutub
Page ID : 289156601188161
Page Username: Eutub
*/
$fanpage = 'eutub';
echo fb_count($fanpage); // result: 116093 likes.
// This will return the number of fan in your Facebook page.
?>
Comments