Finding page id of Facebook fan-page


Sometimes you come to a situation when you need the page id of the Facebook fan page. This happens usually when you are writing Facebook application that needs to use the Facebook fan-pages. If you have been to the situation then here's you solution. It just a few lines of code
which is as follows:
<?php
/**
* A simple library to assist in getting the Facebook Fan Page Id
* @author Paras Nath Chaudhary
* @copyright CopyLeft (ↄ) 2013, writephp.blogspot.com
* @license GPL
* @since Version 1.0
* @version 1.0
Implementation
================
<?php
require_once 'facebookHelper.php';
echo getPageId("http://www.facebook.com/nosklub");
?>
*/
function getPageId($fanpageUrl){
$url=str_replace('www', 'graph', $fanpageUrl);
$json = file_get_contents($url);
$contents=json_decode($json);
return $contents->id;
}
?>
This simple program echoes your Facebook fan-page when "http://www.facebook.com/nosklub" is replaced with the url of your Facebook Fan-page.
No rocket science right?  :) And yeah one more thing to add, this not only just gives you the id of your fanpage, it also returns the facebook id of the user, supplied the persons facebook url e.g. http://www.facebook.com/opnchaudhary

Comments

Popular posts from this blog

Automate file upload in Selenium IDE

How To Install and Configure Nextcloud

Google translate adds Nepali Language Conversion