Reputation: 1
I am currently updating an older Facebook app to version 4.0 of the Facebook PHP SDK. The app simply posts messages to the user's wall, thus requesting the publish_actions permission from the user. Since the app has not yet been submitted for app review, I am testing with a developer account and one test user account.
When I log in to the test user account and open the app, the app checks whether the publish_actions permission has been granted. In my scenario, this works fine for the test user:
FacebookSession::setDefaultApplication($config['appId'], $config['secret']);
$helper = new FacebookCanvasLoginHelper();
try {
$session = $helper->getSession();
} catch(FacebookRequestException $ex) {
// When Facebook returns an error
} catch(\Exception $ex) {
// When validation fails or other local issues
}
if($session) { //When app installed
$request_perm = new FacebookRequest($session, 'GET', '/me/permissions');
$response_perm = $request_perm->execute();
$graphObjectPermissions = $response_perm->getGraphObject()->asArray();
$permissions = [];
foreach ($graphObjectPermissions as $key => $permObject) {
$permissions[$permObject->permission] = $permObject->status;
}
if(array_key_exists('publish_actions', $permissions) && $permissions['publish_actions']=='granted'){
echo "Permission granted!";
}
However, when I log in to the developer account and query the permissions of the test user with GET user_id/permissions, the returned graphObject does not contain the permission publish_actions at all (only email and public profile).
array ( 'email' => 'granted', 'public_profile' => 'granted', )
This is the code for the request, $access_token contains the app access token of my app.
$thisSession = new FacebookSession($access_token);
$request_perm = new FacebookRequest($thisSession, 'GET', '/' . $data['user_id'] . '/permissions');
$response_perm = $request_perm->execute();
$graphObjectPermissions = $response_perm->getGraphObject()->asArray();
$permissions = [];//create permissions array
foreach ($graphObjectPermissions as $key => $permObject) {
$permissions[$permObject->permission] = $permObject->status;
}
var_export($permissions);
What do I need to change/do in order to check the publish_actions permission from the developer account using GET user_id/permissions?
Upvotes: 0
Views: 883