I would like to send messages to a Facebook page with PHP but I have this error
(#200) The user hasn't authorized the application to perform this action.
I'm the administrator of the Facebook page and the Facebook application.
I think I have this problems because I don't have the good permissions but I don't know how to have this.
I have search in many many pages with same question in the web but I don't have find the answer.
They are my permissions.
array(1) {
["data"]=> array(3) {
[0]=> array(2) {
["permission"]=> string(9) "installed"
["status"]=> string(7) "granted"
}
[1]=> array(2) {
["permission"]=> string(14)"public_profile"
["status"]=> string(7) "granted"
}
[2]=> array(2) {
["permission"]=> string(12) "manage_pages"
["status"]=> string(7) "granted" } } }
And this is my code.
$permissions = 'manage_pages, publish_stream';
$fb = new Facebook(array('appId'=>$appId, 'secret'=>$secret));
$fbuser = $fb->getUser();
if($fbuser){
$permissions = $fb->api('/me/permissions');
if(isset($_POST['msg']) and $_POST['msg']!=''){
try{
$message = array(
'access_token' => $token,
'message' => $_POST['msg']
);
// $posturl = '/'.$_POST['pageid'].'/feed';
$posturl = '/me/feed';
$result = $fb->api($posturl,'POST',$message);
if($result){
echo 'Successfully posted to Facebook Wall...';
}
}catch(FacebookApiException $e){
echo $e->getMessage();
}
}
...
}else{
$fbloginurl = $fb->getLoginUrl(array('redirect-uri'=>$returnurl, 'scope'=>$permissions));
echo '<a href="'.$fbloginurl.'">Login with Facebook</a>';
}
Definition of error 1a : an act or condition of ignorant or imprudent deviation from a code of behavior. b : an act involving an unintentional deviation from truth or accuracy made an error in adding up the bill.
: something that is not correct : a wrong action or statement : mistake. [count] I made an error in my calculations. They uncovered several errors in his report to the committee.
Opposite of an erroneous belief, idea, or conception. truth. verity. truthfulness. accuracy.
You can see in the response that the publishing permission is not granted.
The reason is that publish_stream
is now deprecated; use publish_actions
instead.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With