启动facebook应用程序时,我要求使用scope
参数获得一些额外的权限。有什么方法我可以立即知道用户拒绝了哪些权限?
答案 0 :(得分:3)
这是一个简单的函数(从我编写的类中修改以简化Facebook API调用),以检查Facebook应用程序的“范围”与用户授予的权限之间是否存在差异。
function checkPermissions($scope, $facebook)
{
// Break the scope into an array
$scope = array_map('trim', explode(",", $scope));
// Get the users permissions from Facebook and put them in an array
$getUserPerms = $facebook->api('/me/permissions');
$userPerms = array_keys($getUserPerms['data'][0]);
// Permissions not granted is the difference between these arrys
$ungrantedPerms = array_diff($scope, $userPerms);
if ( ! empty($ungrantedPerms)) {
// authenticate user again
}
}
假设范围的格式如下:
$scope = 'email, user_about_me, user_likes, manage_pages, publish_stream';
答案 1 :(得分:1)