当我在文本框中输入一些内容并上传图像并提交时,该帖子应发布在特定用户的 Facebook 时间线中。这是我编写的代码,但它不起作用:
<html>
<head>
<script src='http://connect.facebook.net/en_US/all.js'></script>
</head>
<body>
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : 'App ID', // App ID
channelUrl : '//mynetwork.net/', // 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.authResponseChange', function(response) {
if (response.status === 'connected') {
testAPI();
} else if (response.status === 'not_authorized') {
FB.login();
} else {
FB.login();
}
});
};
(function(d){
var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all.js";
ref.parentNode.insertBefore(js, ref);
}(document));
function testAPI() {
console.log('Welcome! Fetching your information.... ');
FB.api('/me', function(response) {
console.log('Good to see you, ' + response.name + '.');
});
}
</script>
<script>
var params = {};
params['message'] = 'Message eqwe';
params['name'] = 'wqe wqeweq Name';
params['description'] = 'wqe wDescription';
params['link'] = 'https://www.facebook.com/nvidarshana?fref=ts';
params['picture'] = 'http://summer-mourning.zoocha.com/uploads/thumb.png';
params['caption'] = 'Caption';
FB.api('/me/feed', 'post', params, function(response) {
if (!response || response.error) {
console.log(response.error);
alert(response.error);
} else {
alert('Published to stream - you might want to delete it now!');
}
});
</script>
<fb:login-button show-faces="true" width="200" max-rows="1"></fb:login-button>
</body>
</html>
我已经更新了我的代码,仍然收到错误
"Object {message: "必须使用活动访问令牌来查询当前用户的信息。", type: "OAuthException", code: 2500} "