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

13,066

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.

Share:
13,066
user3065090
Author by

user3065090

Updated on July 25, 2022

Comments

  • user3065090
    user3065090 almost 2 years

    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>';
     }