Facebook OAuthException:“用户尚未授权应用程序执行此操作” [英] Facebook OAuthException: "user hasn't authorized the application to perform this action"

查看:136
本文介绍了Facebook OAuthException:“用户尚未授权应用程序执行此操作”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Facebook PHP SDK,当我尝试发布状态更新时,我收到以下错误:

Using the Facebook PHP SDK, I'm getting the following error when I try to post a status update:


致命错误:未知OAuthException:
(#200)用户尚未授权
应用程序执行此操作

Fatal error: Uncaught OAuthException: (#200) The user hasn't authorized the application to perform this action

这些是我采取的步骤:


  1. 获取代码:

  1. Get code:

https://graph.facebook.com/oauth/authorize?client_id=FB_APP_ID&redirect_uri=REDIRECT_URI


  • 获取访问令牌:

  • Get access token:

    https://graph.facebook.com/oauth/access_token?client_id=FB_APP_ID&code=CODE&client_secret= FB_SECRET&redirect_uri=REDIRECT_URI
    


  • 尝试状态更新:

  • Attempt the status update:

    require_once(facebook.php);
    $fb = new Facebook(array(
        'appId' => FB_APP_ID,
        'secret' => FB_SECRET
    ));
    $post = $fb->api('me/feed', 'POST', array(
        'access_token' => ACCESS_TOKEN, 
        'message' => 'hello world!'
    ));
    


  • 我没有看到任何设置应用程序将授权应用程序执行此操作,但也许我错过了一些。任何建议?

    I don't see any settings in my application that would authorize the application to do this, but maybe I'm missing something. Any suggestions?

    推荐答案

    确保您要求扩展 publish_stream 权限您要求代码(作为第三个参数添加):

    Make sure you ask for extended publish_stream permission when you're requesting code (added as the third parameter):

    https://graph.facebook.com/oauth/authorize?client_id=' . FB_APP_ID . '&redirect_uri=' . REDIRECT_URI . '&scope=publish_stream'
    

    希望这有帮助。

    干杯!

    这篇关于Facebook OAuthException:“用户尚未授权应用程序执行此操作”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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