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
这些是我采取的步骤:
-
获取代码:
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屋!