如果用户是facebook中的应用程序管理员,我可以以某种方式得到这个吗?
答案 0 :(得分:6)
要获得此类信息,您可以使用FQL:
protected function authorizeByFb(){
$result = $this->fb->api(array(
'method' => 'fql.query',
'query' => "SELECT developer_id FROM developer WHERE application_id='{$appId}' AND developer_id='{$fbUserId}'",
));
if(count($result)==1){
return true;
}
return false;
}
答案 1 :(得分:2)
如果您开发的应用程序正在检查登录的Facebook用户的角色,或者只是您的应用程序想要识别它的所有者或管理员, 然后 http://developers.facebook.com/tools/explorer/?method=GET&path=me%2Faccounts应该列出该应用程序ID
FB.api('/me/accounts', 'get', {"access_token":access_token}, function(response){
//loop through response to check any application id matches current application id
});
{
"name": "app_name",
"access_token": "current_token_here",
"category": "Application",
"id": "your_owned_app_id"
},
{
"name": "app_name1",
"access_token": "current_token_here",
"category": "Application",
"id": "your_owned_app1_id"
},
答案 2 :(得分:1)
我刚刚使用Facebook JS API工作:
FB.api({ method: 'pages.isAdmin', page_id : fbAppId }, function(response){
if(response){
alert('the user is an admin');
}else{
alert('the user is not an admin')
}
});
它使用FB.api方法访问旧的REST API。这假设您已经调用了FB.init,因此请确保它在您的初始化代码之后。
干杯,
杰里米
答案 3 :(得分:0)
您可以获取signed_request,然后检查page_admin = 1
<?php
$signed_request = $facebook->getSignedRequest();
$page_admin = $signed_request["page"]["admin"];
if ( $page_admin == 1 ){
echo 'Welcome Admin!';
}
?>
答案 4 :(得分:0)
我尝试尝试上面的javascript表单,并发现此方法可以替代旧的restful api折旧。
function checkAdmin(fbUID, fbAppID){
FB.api({
method: 'fql.query',
query: 'SELECT role FROM app_role WHERE developer_id ='+fbUID+' AND application_id = '+fbAppID
},
function(response) {
if(response.length){
alert('User is an Admin');
}
else{
alert('User is not an Admin')
}
});
}