最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Facebook feed dialog not working - Stack Overflow

programmeradmin1浏览0评论

I am trying to get the Facebook Feed dialog to work at a test site but I keep getting the same error message: "An error occurred with [app_name]. Please try again later.". When I look at the documentation I realize that the example in the documentation doesn't work either.

Have tried a number of different solutions. Here is my test code:

 <html xmlns:fb="">
  <body>
  <div id="fb-root"></div>
<script>
  window.fbAsyncInit = function() {
    // init the FB JS SDK
    FB.init({
      appId      : '400714233333865', // App ID from the App Dashboard
      channelUrl : '//demo.xxxxxxx.se/nptest/channel.html', // Channel File for x-domain munication
      status     : true, // check the login status upon init?
      cookie     : true, // set sessions cookies to allow your server to access the session?
      xfbml      : true  // parse XFBML tags on this page?
    });

    // Additional initialization code such as adding Event Listeners goes here

  };

  function postToFeed(){

  FB.ui(
  {
   method: 'feed',
   name: 'The Facebook SDK for Javascript',
   caption: 'Bringing Facebook to the desktop and mobile web',
   description: (
      'A small JavaScript library that allows you to harness ' +
      'the power of Facebook, bringing the user\'s identity, ' +
      'social graph and distribution power to your site.'
   ),
   link: '/',
   picture: '.jpg'
  },
  function(response) {
    if (response && response.post_id) {
      alert('Post was published.');
    } else {
      alert('Post was not published.');
    }
  }
);

};

  // Load the SDK's source Asynchronously
  (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/en_US/all.js";
     ref.parentNode.insertBefore(js, ref);
   }(document));
</script>



     <div id='fb-root'></div>
<a onClick="postToFeed('Text');">
    Share in the feeeeeeeeeeeeed
</a>
  </body>
</html>

Has anyone e across a similar issue or a solution for this?

I am trying to get the Facebook Feed dialog to work at a test site but I keep getting the same error message: "An error occurred with [app_name]. Please try again later.". When I look at the documentation I realize that the example in the documentation doesn't work either.

Have tried a number of different solutions. Here is my test code:

 <html xmlns:fb="https://www.facebook./2008/fbml">
  <body>
  <div id="fb-root"></div>
<script>
  window.fbAsyncInit = function() {
    // init the FB JS SDK
    FB.init({
      appId      : '400714233333865', // App ID from the App Dashboard
      channelUrl : '//demo.xxxxxxx.se/nptest/channel.html', // Channel File for x-domain munication
      status     : true, // check the login status upon init?
      cookie     : true, // set sessions cookies to allow your server to access the session?
      xfbml      : true  // parse XFBML tags on this page?
    });

    // Additional initialization code such as adding Event Listeners goes here

  };

  function postToFeed(){

  FB.ui(
  {
   method: 'feed',
   name: 'The Facebook SDK for Javascript',
   caption: 'Bringing Facebook to the desktop and mobile web',
   description: (
      'A small JavaScript library that allows you to harness ' +
      'the power of Facebook, bringing the user\'s identity, ' +
      'social graph and distribution power to your site.'
   ),
   link: 'https://developers.facebook./docs/reference/javascript/',
   picture: 'http://www.fbrell./public/f8.jpg'
  },
  function(response) {
    if (response && response.post_id) {
      alert('Post was published.');
    } else {
      alert('Post was not published.');
    }
  }
);

};

  // Load the SDK's source Asynchronously
  (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/en_US/all.js";
     ref.parentNode.insertBefore(js, ref);
   }(document));
</script>



     <div id='fb-root'></div>
<a onClick="postToFeed('Text');">
    Share in the feeeeeeeeeeeeed
</a>
  </body>
</html>

Has anyone e across a similar issue or a solution for this?

Share Improve this question edited Nov 17, 2015 at 11:16 Somnath Muluk 58k38 gold badges224 silver badges230 bronze badges asked Oct 22, 2012 at 12:42 PaperThickPaperThick 2,7994 gold badges25 silver badges42 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 3

Make sure that you are testing through same URL as specified in Application settings. In your feed dialog give your own links and images i.e. links of your own domain specified in Application setting and not one given in Facebook example.

发布评论

评论列表(0)

  1. 暂无评论