Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error (#200) The user hasn't authorized the application to perform this action

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>';
 }
like image 764
user3065090 Avatar asked Jul 08 '14 12:07

user3065090


People also ask

What do you mean of error?

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.

What is an error with example?

: 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.

What is opposite of error?

Opposite of an erroneous belief, idea, or conception. truth. verity. truthfulness. accuracy.


1 Answers

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.

like image 63
Sahil Mittal Avatar answered Nov 05 '22 23:11

Sahil Mittal