PHP sdk到facebook页面帖子,Uncaught OAuthException:(#200)

时间:2013-02-18 13:41:31

标签: php facebook facebook-graph-api

我一直在:

“未捕获OAuthException:(#200)用户尚未授权应用程序执行此操作”

require_once("resources/facebook_sdk/facebook.php");

    $app_id       = 'appid';
    $app_secret   = 'appsecret';


    $facebook = new Facebook(array(
        'appId' => $app_id,
        'secret' => $app_secret,
        'cookie' => true
    ));

    $user = $facebook->getUser();
    if($user)
    {

        $access_token=  $facebook->getAccessToken();

    }

    else {

        $loginUrl = $facebook->getLoginUrl(array(
            'canvas' => 1,
            'fbconnect' => 0,
            'scope' => 'offline_access,read_stream,user_photos,user_videos,publish_stream,manage_pages'
        ));
        echo ("<script> top.location.href='".$loginUrl."'</script>");
    }




    $req =  array(
        'access_token' => $access_token,
        'name' => 'My wall post',
        'message' => 'tralalala',
        'caption' => "www.mysite.com",
        'link' => 'http://www.mysite.com',
        'description' => 'Wall post',
        'picture' => 'http://farm6.static.flickr.com/1111/some-pic.jpg',
        'actions' => array(array('name' => 'My Site',
            'link' => 'http://www.mysite.com'))
    );

    print_r($req);
    $res = $facebook->api('/pageid/feed' ,'post',$req);
    if ($res) echo "succes";
    else echo "fail";
    print_r($res);

任何想法我做错了,发布流权限给出了什么?

1 个答案:

答案 0 :(得分:1)

这个答案是考虑到您拥有在Facebook上传服务器的所有权利。请查看下面的一些链接以获取更多信息,

Facebook API OAuthException: (#200)

Facebook Open Graph API returns: (#200) Requires extended permission: publish_actions

Uncaught OAuthException: (#200), when trying to post on wall

Multiuser event invite graph api fails Permissions Error:200 OAuthException

您已经提供了在范围内定义的所有权限,

'scope'=>'offline_access,read_stream,user_photos,user_videos,publish_stream,manage_pages';

可以帮到你。