Reputation: 11
I want Event Syncing on user's fan pages on their behalfs. For this first i confirmed that user has the admin rights for given page. I google but I can't figure out that how i checked that user has the admin rights for given page.
Any one has idea??
Upvotes: 1
Views: 777
Reputation: 37
If you're using an iframe application page the best way to do this is:
function parsePageSignedRequest() {
if (isset($_REQUEST['signed_request'])) {
$encoded_sig = null;
$payload = null;
list($encoded_sig, $payload) = explode('.', $_REQUEST['signed_request'], 2);
$sig = base64_decode(strtr($encoded_sig, '-_', '+/'));
$data = json_decode(base64_decode(strtr($payload, '-_', '+/'), true));
return $data;
}
return false;
}
function userIsAdmin() {
if($signed_request = parsePageSignedRequest()) {
return ($signed_request->page->admin) ;
}
else {
return false;
}
}
Cheers
Upvotes: 2
Reputation: 1
Here's some slightly lame code to do it. Warning - it takes almost a second to retrieve the list of pages.
if ($session)
{
# Find out if we're an admin
$adminpages = $facebook->api(array(
'method' => 'fql.query',
'query' => "SELECT page_id FROM page_admin WHERE uid='$uid'",
}
function isAdmin($thisid)
{
global $adminpages;
$pageadmin = false;
if ($adminpages)
{
foreach ($adminpages as $i => $page)
{
if ($page['page_id'] === $thisid)
{
$pageadmin = true;
}
}
}
return($pageadmin);
}
Upvotes: 0