I\'ve got the Facebook user ID of the user who created a given page. Now I need to get the page ID to display like box in my website.
Different users have their own Face
I am presuming that you are the user and you want the page id of a page that you are the admin of.
To get the id is fairly straightforward.
First, you need to get a list of all pages associated with the user id:
$fanpages = $facebook->api('me/accounts?access_token='.$accessToken);
You would then do a loop like:
foreach ($fanpages['data'] as $fanpage)
{
echo "<br />Fan Page Name: ".$fanpage['name'] . " ID: ".$fanpage['id'];
}
That would list all the pages associated with the id.
For a full list of the elements of the $fanpage array, take a look here:
https://developers.facebook.com/docs/reference/api/page/
The URL to the fan page will have the ID in it. For example, the Stack Overflow fan page
http://www.facebook.com/pages/Stack-Overflow/105665906133609
The ID is 105665906133609
Some pages have aliases, which are also usable as the ID. For example, the Marine Corps' fan page is
http://www.facebook.com/marinecorps
So the ID is marinecorps
Alternatively, you can use the generator on the documentation page as well.
You can replace www to graph in the page URL. For example id of the Coca-Cola page http://graph.facebook.com/cocacola (first value).