Some times you need the Facebook pages of a user. You can get it by simple fql. Here is how
// Create our Application instance (replace this with your appId and secret).
$facebook = new Facebook(array(
'appId' => FACEBOOK_APP_ID,
'secret' => FACEBOOK_SECRET_KEY,
'cookie' => false,
));
$user = $facebook->getUser();
$loginUrl = $facebook->getLoginUrl(
array(
'scope' => 'offline_access,email,manage_pages'
)
);
if ($user) {
try {
// Proceed knowing you have a logged in user who's authenticated.
$user_profile = $facebook->api('/me');;
$user_pages = $facebook->api(array('method' => 'fql.query','query' => 'SELECT page_id,page_url,name,pic_square FROM page WHERE page_id IN (SELECT page_id FROM page_admin WHERE uid ='.$user.' )' ));
} catch (FacebookApiException $e) {
$user = null;
}
}
if (!$user or $chk==1) {
echo "<script type='text/javascript'>top.location.href = '$loginUrl';</script>";
}
$user_pages will have the information about the pages that the user admin of. See this code in this post