Facebook OAuthException:“用户尚未授权应用程序执行此操作"; [英] Facebook OAuthException: "user hasn't authorized the application to perform this action"
问题描述
使用 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
这些是我已经采取的步骤:
These are the steps I've taken:
获取代码:
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屋!