當我在文本框中鍵入一些內容並上傳圖片並提交時,帖子應該發佈在特定用戶的Facebook時間軸中。這是我編寫的代碼,但itz不起作用:通過我的網站發佈到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>
我已經更新了我的代碼,仍然歌廳錯誤
「對象{消息:‘一個積極的訪問令牌必須用於查詢當前用戶的信息’,輸入:」 OAuthException 「,code:2500}」
欣賞!但它也給了我同樣的錯誤! – nanbatman
你能告訴我確切的錯誤嗎? '的console.log(響應)'。並定義了「FB」? –
'錯誤發生'這是我每次得到的。你的意思是「FB定義」,我在上面發佈了我的完整代碼。我應該如何定義FB? – nanbatman