我使用 facebook 演示代码从 facebook api 获取活动提要到网站,如下编码,但它不起作用。
我在下面的代码中犯了什么错误以及如何解决它?
<script>
window.fbAsyncInit = function() {
// init the FB JS SDK
FB.init({
appId : '505956199488509', // App ID from the app dashboard
channelUrl : '//http://203.186.112.99/php/fb_demo/channel.html', // Channel file for x-domain comms
status : true, // Check Facebook Login status
xfbml : true // Look for social plugins on the page
});
// Additional initialization code such as adding Event Listeners goes here
};
// Load the SDK asynchronously
(function(d, s, id){
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/all.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
function LoadFeed() {
FB.api('/platform/posts', { limit: 3 }, function(response) {
for (var i=0, l=response.length; i<l; i++) {
var post = response[i];
if (post.message) {
alert('Message: ' + post.message);
} else if (post.attachment && post.attachment.name) {
alert('Attachment: ' + post.attachment.name);
}
}
});
}
</script>
谢谢你。