Reputation: 625
I have to develop an app that can post to user's walls even if he is offline. Everything is implemented and it works. The problem is that if the user just removes the access to post, the app don't get any notification so I can not update, and if user has removed access and I try to post from his account using /me/feed and his access_token, instead of just failing to post and continuing it simply crashes hence other user's posts are not updated as well.
I am trying to check permissions but that is not working either. It works fine if I hit in URL directly
https://graph.facebook.com/userID/permissions?access_token=123
But when I try to do the same thing using php it simply doesn't work or returns me empty result. I have tried post of the following:
$response = $facebook->api("/$userId/permissions?access_token=$accessToken");
As well as
$params1 = array();
$params1['access_token'] = $accessToken;
$response = $facebook->api("/$userId/permissions", 'POST', $params1);
Any ideas?
Upvotes: 1
Views: 1681
Reputation: 11297
First I want to hint something here, Did you use:
$facebook->setAccessToken($myToken);
Because this will cause Facebook to send duplicate variables (parameters) since you used
$facebook->api("/$userId/permissions?access_token=$accessToken");
Additionally you can use:
$permissions = $facebook->api("/me/permissions");
if( array_key_exists('publish_stream', $permissions['data'][0]) ) {
// Permission is granted!
// Do the related task
$post_id = $facebook->api('/me/feed', 'post', array('message'=>'Hello World!'));
} else {
// We don't have the permission
// Alert the user or ask for the permission!
header( "Location: " . $facebook->getLoginUrl(array("scope" => "publish_stream")) );
}
Source:
How to: Check if User Has Certian Permission – Facebook API
Upvotes: 2