(#200)用户没有授权应用程序执行此操作facebook php api错误? [英] (#200) The user hasn't authorized the application to perform this action facebook php api error?

查看:117
本文介绍了(#200)用户没有授权应用程序执行此操作facebook php api错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用以下代码来发布到Facebook页面,但是我收到此错误:

I am using the following code in order to post to facebook page but I get this error:

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

我得到manage_page权限对话框,我点击好的,一切都很好,所以我不明白为什么我不能发布到Facebook页面!

I get the manage_page permission dialog and I click ok and everything's fine there so I don't understand why I cannot post to the facebook page!

这是我的代码:

<?php
 include_once 'inc/facebook.php';

 $appId = '000000000000000';
 $secret = '00000000000000000000000';
 $returnurl = 'https://mrdomain.com';
 $permissions = 'manage_pages, publish_stream';

 $fb = new Facebook(array('appId'=>$appId, 'secret'=>$secret));

 $fbuser = $fb->getUser();

 if($fbuser){

    if(isset($_POST['msg']) and $_POST['msg']!=''){
        try{
            $message = array(
                'message' => $_POST['msg']
            );
            $posturl = '/'.$_POST['pageid'].'/feed';
            $result = $fb->api($posturl,'POST',$message);
            if($result){
                echo 'Successfully posted to Facebook Wall...';
            }
        }catch(FacebookApiException $e){
            echo $e->getMessage();
        }
    }

    try{
        $qry = 'select page_id, name from page where page_id in (select page_id from page_admin where uid ='.$fbuser.')';
        $pages = $fb->api(array('method' => 'fql.query','query' => $qry));

        if(empty($pages)){
            echo 'The user does not have any pages.';
        }else{
            echo '<form action="" method="post">';
            echo 'Select Page: <select name="pageid">';
            foreach($pages as $page){
                echo '<option value="'.$page['page_id'].'">'.$page['name'].'</option>';
            }
            echo '</select>';
            echo '<br />Message: <textarea name="msg"></textarea>';
            echo '<br /><input type="submit" value="Post to wall" />';
            echo '</form>';
        }

    }catch(FacebookApiException $e){
        echo $e->getMessage();
    }

 }else{
    $fbloginurl = $fb->getLoginUrl(array('redirect-uri'=>$returnurl, 'scope'=>$permissions));
    echo '<a href="'.$fbloginurl.'">Login with Facebook</a>';
 }

?>

在我可以发布到Facebook页面之前,我需要做其他任何事情吗?

do i need to do anything else before I can post to the facebook page?

任何帮助将不胜感激。

推荐答案

文档看起来您正在使用折旧权限,尝试 publish_actions 而不是 publish_stream

From the documentation it looks like you're using a depreciated permission, try publish_actions instead of publish_stream.

这篇关于(#200)用户没有授权应用程序执行此操作facebook php api错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆