我正在尝试使用 javascript sdk 发布到已连接用户的 facebook 墙上,这是我的代码:
var connecter=false;
window.fbAsyncInit = function() {
FB.init({
appId : 'xxxxxxx', // App ID
oauth : true,
channelUrl : '//www.streamazing.net/js/channel.html', // Channel File
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
FB.Event.subscribe('auth.login', function (response) {
window.location.reload();
});
FB.Event.subscribe('auth.logout', function (response) {
window.location.reload();
});
FB.getLoginStatus(function(response) {
if (response.status === 'connected') {
connecter=true;
FB.api('/me', function(user) {
var user2=user;
console.log(user2.name);
});
}
else connecter=false;
});
var body = 'This is a test';
FB.api('/me/feed', 'post', { message: body }, function(response) {
if (!response || response.error) {
console.log(response.error);
} else {
alert('Post ID: ' + response.id);
}
});
};
这是控制台日志:
code: 2500
message: "An active access token must be used to query information about the current user."
type: "OAuthException"
我正在使用此代码请求许可:
<fb:login-button autologoutlink='true' scope='email,user_birthday,status_update,publish_stream'></fb:login-button>
我不明白为什么 facebook 向我询问访问令牌,有人可以帮助我吗?非常感谢。