I am trying to open a feed dialog using the JS SDK's FB.ui method and have it close after the user shares. My problem is the feed dialog is requiring a redirect_uri even though the documentation says it doesn't have to be defined, and the popup window redirects there and will not close like the callback function says.
Here's my code, attached to the submit click event:
FB.ui (
{
method: 'feed',
name: 'xxx!',
link: 'link to FB tab',
picture: 'jpg',
caption: 'xxx',
actions: {name:'xxx',link:'url'},
ref: 'xxx',
redirect_uri: 'link to FB tab'
},
function(response) {
self.close();
}
);
If I leave off the redirect_uri, the popup opens but it just says the FB app has an error and please try again.
It appears this is a known change in Facebook's JavaScript SDK: http://developers.facebook.com/bugs/302946973066993
This is the behavior I'm used to and have been trying to duplicate. A FB dev reports that this is now "by design."
After spending a whole day working on this problem, I have a very good solution that I'd like to share. Instead of using the SDK with FB.ui(), I have discovered that I can avoid it entirely by manually opening my own popup to https://www.facebook.com/dialog/feed. When doing it this way, redirect_uri works as expected, and you can just redirect to an HTML file that closes the popup window. Whether the user clicks on share or cancel, the popup will close as expected.
I don't believe there are any compromises with this code, and if anything, it is much easier to use than the actual SDK.
My Javascript code (which you can save as FacebookFeedDialog.js) looks like this:
Here's a sample HTML file that uses the Javascript code above:
Your closeWindow html file can look like this:
Hmmm, the docs I see says it is required and must be defined....