简体   繁体   中英

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM