【发布时间】:2015-12-01 13:42:23
【问题描述】:
我想从 JavaScript 发布到 Facebook 页面提要(就好像它来自页面一样)。我登录正常,但是当我尝试发布时,它给出了错误
"错误:对象 代码:200 消息:“(#200)权限错误” 类型:“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});
};
【问题讨论】:
标签: javascript facebook-graph-api