我想从 JavaScript 发布到 Facebook 页面提要(就好像它来自页面一样)。我登录正常,但是当我尝试发帖时,出现错误
"error: Object code: 200 message: "(#200) Permissions error" type: "OAuthException"
在登录中,身份验证响应带有以下权限,我认为这些权限已经足够 -
"email,contact_email,manage_pages,publish_pages,publish_actions,public_profile"."
请问我怎样才能让它工作?
主要部件(plunk):
function postToMembers(){
var access_token1 = FB.getAuthResponse()['accessToken'];
var body = 'Post from code test';
FB.api('/41622-PAGEID-34/feed', 'post', { message: body, access_token: access_token1 }, function(response) {
if (!response || response.error) {
console.log(response);
} else {
alert('Post ID: ' + response.id);
}
});
};
function loginAndPost(){
FB.login(function(response) {
if (response.authResponse) {
//Log auth permissions (in the response)
console.log(response);
FB.api('/me', function(response) {
console.log('Successful login for: ' + response.name);
document.getElementById('status').innerHTML =
'Thanks for logging in, ' + response.name + '!';
});
postToMembers();
} else {
console.log('User cancelled login or did not fully authorize.');
}
}, {scope: 'publish_actions,publish_pages,manage_pages', return_scopes: true});
};
最佳答案
没有名为“contact_email”的权限,只有“email”。
话虽这么说,您需要一个页面 token 才能“作为页面”发布。使用/me/accounts
为您的页面获取页面 token 。权限错误很可能意味着您没有适当的权限使用访问 token 发布到页面。确保它是您管理的主页,并确保访问 token 包含 publish_pages
权限。您可以在调试器中调试您的访问 token :https://developers.facebook.com/tools/debug/
此外,请确保您正在尝试使用应用程序管理员。未经审查,这些附加权限仅适用于在应用程序中具有 Angular 色的用户。请参阅文档中有关登录审核的信息:https://developers.facebook.com/docs/facebook-login/review
关于javascript - Facebook Graph API - (#200) 页面发布权限错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32414301/