如何通过facebook api获取网站的活动源?

时间:2013-09-16 04:26:44

标签: javascript facebook facebook-javascript-sdk

我使用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>

谢谢。

0 个答案:

没有答案