After spending the whole day working on this issue, I have a very good solution that I would like to share. Instead of using the SDK with FB.ui (), I found that I could completely avoid this by manually opening my own popup for https://www.facebook.com/dialog/feed , Thus, redirect_uri works like expected. As long as you require the user to click a button to open a dialog box, a pop-up blocker will not start.
I do not believe that there are any compromises with this code, and, in any case, it is much easier to use than the actual SDK.
My Javascript code (which you can save as FacebookFeedDialog.js) is as follows:
function FacebookFeedDialog(appID, linkTarget, redirectTarget) { this.mParams = { app_id: appID, link: linkTarget, redirect_uri: redirectTarget, display: "popup" } }; FacebookFeedDialog.prototype.addParam = function(key, value) { this.mParams[key] = value; }; FacebookFeedDialog.prototype.open = function() { var url = 'https://www.facebook.com/dialog/feed?' + encodeCGIArgs(this.mParams); popup(url, 'feedDialog', 700, 400); }; function encodeCGIArgs(paramObject) { var result = ''; for (var key in paramObject) { if (result) result += '&'; result += encodeURIComponent(key) + '=' + encodeURIComponent(paramObject[key]); } return result; } function popup(mylink,windowname,width,height) { if (!window.focus) return; var href; if (typeof(mylink) == 'string') href=mylink; else href=mylink.href; if (!windowname) windowname='mywindow'; if (!width) width=600; if (!height) height=350; window.open(href, windowname, 'resizable=yes,width='+width+',height='+height+',scrollbars=yes'); }
Here is an example HTML file that uses the Javascript code above:
<HTML> <BODY> <SCRIPT type="text/javascript" src="FacebookFeedDialog.js"></SCRIPT> <SCRIPT> var dialog = new FacebookFeedDialog(yourAppIDGoesHere,yourDestinationURLGoesHere,yourCloseWindowURLGoesHere); dialog.addParam('name','This is my title'); dialog.addParam('description','This is the description'); dialog.addParam('picture',yourImageURLGoesHere); dialog.addParam('caption','This is the caption'); </SCRIPT> <A href="javascript:dialog.open()">Open facebook dialog</A> </BODY> </HTML>
Your html CloseWindow file might look like this:
<SCRIPT> window.close(); </SCRIPT>