我正试图通过FB API
在Facebook墙上发布并在控制台中收到此错误。
error
Object { message="(#200) The user hasn't a... to perform this action", type="OAuthException", code=200}
code 200
message
"(#200) The user hasn't authorized the application to perform this action"
type :"OAuthException"
我正在尝试这种方式。
<div id="fb-root"></div>
<script type="text/javascript">
(function() {
var e = document.createElement('script');
// replacing with an older version until FB fixes the cancel-login bug
e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
//e.src = 'scripts/all.js';
e.async = true;
document.getElementById('fb-root').appendChild(e);
}());
window.fbAsyncInit = function()
{
FB.init({
appId : 'XXXXXXXXXXXXXXXXXXX',
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true , // parse XFBML
oauth : true // Enable oauth authentication
});
};
function post_on_wall()
{
FB.login(function(response)
{
if (response.authResponse)
{
alert('Logged in!');
// Post message to your wall
var opts = {
message : document.getElementById('fb_message').value,
name : 'Post Title',
link : 'xxxxxxxxxxxxxxxx',
description : 'post description Nanital',
picture : 'ImageLink'
};
FB.api('/me/feed', 'post', opts, function(response)
{
if (!response || response.error)
{
alert('Posting error occured');
}
else
{
alert('Success - Post ID: ' + response.id);
}
});
}
else
{
alert('Not logged in');
}
}, { scope : 'publish_stream' });
}
</script>
注意:它工作正常,如果我使用相同的ID登录,我通过我创建此APP。但不适用于其他Facebook用户。
答案 0 :(得分:0)
首先,publish_stream
已被弃用多年。您需要publish_actions
:
具有publish_actions权限的用户访问令牌可用于发布新帖子
来源:https://developers.facebook.com/docs/graph-api/reference/v2.2/user/feed
话虽如此,您需要使用publish_actions
完成审核流程,然后才能将其用于其他所有用户:https://developers.facebook.com/docs/apps/review/login