Reputation: 46728
I am asking for a few extra permissions using the scope
parameter when launching the facebook application. Is there any way I can know immediately which permissions have been denied by the user?
Upvotes: 2
Views: 3034
Reputation: 127
Here is a simple function (modified from a class I wrote to simplify Facebook API calls) to check if there are discrepencies between the 'scope' of the Facebook app and the permissions granted by the user.
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
}
}
Is assumes the scope is formatted in the following way:
$scope = 'email, user_about_me, user_likes, manage_pages, publish_stream';
Upvotes: 3
Reputation: 31870
Query: https://developers.facebook.com/tools/explorer/?method=GET&path=me%2Fpermissions
See https://developers.facebook.com/docs/reference/api/user/ for more information on the user object's permissions connection.
Upvotes: 1