gpt4 book ai didi

facebook - 发布到 Facebook 错误 : '(#200) The user hasn\' t authorized the application to perform this action', 类型 : 'OAuthException' , 代码:200

转载 作者:太空宇宙 更新时间:2023-11-04 01:04:31 40 4
gpt4 key购买 nike

当我尝试从我的应用程序通过 facebook 发布内容时,出现以下错误,问题是应用程序没有请求发布操作权限这是代码

var access_token = 'access_token'
FB.setAccessToken(access_token);

var body = '2 4 6 8 8.5';
FB.api('me/feed', 'post',{ message: body, access_token:access_token}, function (res) {
if(!res || res.error) {
console.log(!res ? 'error occurred' : res.error);
return;
}

{ message: '(#200) 用户尚未授权应用程序执行此操作', 类型:'OAuthException', 代码:200 }

我还有一个问题应该使用什么访问 token 用户的访问 token 、应用程序访问 token 还是什么?

最佳答案

您需要用户允许publish_actions扩展权限才能允许您的应用发布到Facebook。

请参阅 me/feed 的发布部分引用:“具有publish_actions权限的用户访问 token 可用于发布新帖子”。需要提示用户“您是否可以将此应用发布到 Facebook”并接受此访问 token 才能工作。

请注意,最好在尝试发布之前检查用户的权限,您可以通过查看 me/permissions 端点进行检查:

{
"data": [
{
"permission": "installed",
"status": "granted"
},
{
"permission": "public_profile",
"status": "granted"
},
{
"permission": "publish_actions",
"status": "granted"
},
{
"permission": "user_friends",
"status": "granted"
}
]
}

您可以通过运行获取此数据:

FB.api("/me/permissions", function (response) {
// data here
});

要请求用户许可,您需要在运行 FB.login 对话框时将“publish_actions”添加到 scope 中:

 FB.login(function(response) {
// handle the response
}, {scope: 'publish_actions'});

关于facebook - 发布到 Facebook 错误 : '(#200) The user hasn\' t authorized the application to perform this action', 类型 : 'OAuthException' , 代码:200,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24339061/

40 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com