Posts

Showing posts from March, 2013

HOWTO in PHP: Retrieve a list of Facebook Pages you are the Administrator of using Graph API

Image
Here's the code. I am assuming here that you have already logged in as a valid Facebook user with the "manage_pages" scope permission. <?php require_once("fbphpsdk/facebook.php"); $config = array(); $config['appId'] = 'YOUR_APP_ID'; $config['secret'] = 'YOUR_APP_SECRET'; $config['fileUpload'] = false; // optional $facebook = new Facebook($config); $uid = $facebook->getUser(); $accesstoken = $facebook->getAccessToken(); $params = array('access_token' => $accesstoken); if ($uid) { try { $userprofile = $facebook->api('/me','GET'); echo "Name: " . $userprofile['name']; $accounts = $facebook->api('/me/accounts', 'GET', $params); foreach($accounts['data'] as $account) { echo "<hr/>" . $account['name'] . " " . $account['id'] . "<br/>...

How to get the Page ID of a Facebook Page from its username

Image
It is very easy Just type this in the addressbar of your browser and press enter. http://graph.facebook.com/<pageurl>/ E.g. when I type the following URL of my own Facebook Page, I yield the results as in Figure 1 below. http://graph.facebook.com/dorathetechplorer/ Hence, the Page ID of my page would be "157472464323620". Figure 1: Output from typing "http://graph.facebook.com/dorathetechplorer"