我在启动 facebook 应用程序时使用 scope
参数请求一些额外的权限。有什么方法可以立即知道用户拒绝了哪些权限?
最佳答案
这是一个简单的函数(根据我为简化 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';
关于facebook - 检测用户是否拒绝了我的 Facebook 应用程序中的任何权限,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9656339/