0

我尝试使用 facebook api 和离线访问令牌在我的墙上发帖。每次我犯一个错误:

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

这是我的代码:

require 'api/facebook.php';

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

    $facebook->setFileUploadSupport(true);  

    $access_token = $facebook->getAccessToken();
    $user_id = $facebook->getUser();

$result = mysql_query("UPDATE users SET user_id_facebook='".$user_id."' WHERE id='".$myrow2['id']."'",$db);
$result = mysql_query("UPDATE users SET access_token_facebook='".$access_token."' WHERE id='".$myrow2['id']."'",$db);

    if($user_id == 0 || $user_id == "")
    {
        $login_url = $facebook->getLoginUrl(array(
        'redirect_uri'         => "http://apps.facebook.com/rapid-apps/",
        'scope'      => "email,publish_stream,user_hometown,user_location,user_photos,friends_photos,
                    user_photo_video_tags,friends_photo_video_tags,user_videos,video_upload,friends_videos,offline_access"));

        echo "<script type='text/javascript'>top.location.href = '$login_url';</script>";
        exit();
    }

    $post =  array(
    'access_token' => $access_token,
    'message' => 'This message is posted with access token - '
);

$res = $facebook->api('/me/feed', 'POST', $post);
4

2 回答 2

1

自 5 月 2 日起,offline_access 权限将被弃用,不应再使用

与此同时,您可以选择通过开发​​人员网站为您的应用程序禁用此弃用 ( https://developers.facebook.com/apps/330955886953999 )...

有关删除的更多信息,请参阅:http: //developers.facebook.com/roadmap/offline-access-removal/

于 2012-04-13T23:35:04.637 回答
0

您需要在发送给用户的初始应用授权请求中调整权限。默认情况下,您只能获得对其基本信息的只读访问权限。

请参阅http://developers.facebook.com/docs/authentication/permissions/

于 2012-08-15T15:31:48.187 回答