Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting error when trying to open a feed dialog

I am getting the following error when trying to open a feed dialog..

An error occurred. Please try again later.

Do I need to have users authorize the app to post on their wall? I was thinking it wouldn't because this would not be something that gets published to the user's wall automatically by the app itself. Plus I'm getting the error when I'm using my admin account.

Here is my code:

<script>
  window.fbAsyncInit = function() {
    FB.init({
  appId      : 'xxxxxxxxxxxxxxx', // App ID
  channelURL : 'http://localhost/foods/channel.html', // Channel File
  status     : true, // check login status
  cookie     : true, // enable cookies to allow the server to access the session
  oauth      : true, // enable OAuth 2.0
  xfbml      : true  // parse XFBML
});

// Additional initialization code here
  };

  // Load the SDK Asynchronously
  (function(d){
 var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
 js = d.createElement('script'); js.id = id; js.async = true;
 js.src = "//connect.facebook.net/en_US/all.js";
 d.getElementsByTagName('head')[0].appendChild(js);
}(document));


function postToFeed() {

    // calling the API ...
    var obj = {
      method: 'feed',
      link: 'https://developers.facebook.com/docs/reference/dialogs/',
      picture: 'http://fbrell.com/f8.jpg',
      name: 'Facebook Dialogs',
      caption: 'Reference Documentation',
      description: 'Using Dialogs to interact with users.'
    };

    function callback(response) {
      document.getElementById('msg').innerHTML = "Post ID: " + response['post_id'];
    }

    FB.ui(obj, callback);
  }
</script>

<a href="javascript:void();" onclick="postToFeed();"><img src="images/share.gif" /></a>
like image 430
Dustin Avatar asked Nov 17 '11 19:11

Dustin


2 Answers

This seems to happen when Facebook finds some mismatch between your app settings and the URL you're trying to share. I found in my case it was happening because I had the wrong app ID set in my FB.init. AFAIK the URL you're sharing has to correspond to the Site URL in your app settings in http://developers.facebook.com/apps.

See this thread for some more tips.

like image 97
And Finally Avatar answered Oct 23 '22 14:10

And Finally


I had the same problem. I was trying to open a Feed dialog automatically after page load. And 9 times of 10 it displayed this error. The code was in $(document).ready jQuery function. And it seems that some facebook stuff had not yet been loaded at the point the code was to be executed. I moved the code to $(window).load block (which is executed after all page content is loaded), and the problem has been solved.

like image 31
Dennis Golomazov Avatar answered Oct 23 '22 14:10

Dennis Golomazov