I am trying to have a FB.ui dialog box appear on button click for a user. Right now, I can get the dialog box to appear as a pop up, but I do not want this. I want the dialog box to appear as a modal, so that pop-up blockers don't block it. I have tried using the "display: 'iframe'" parameter, but when using this I get the error:
"dialog" mode can only be used when the user is connected.
I have read that perhaps I need to use an access token to get this to appear as a modal and use the display iframe parameter. Keep in mind this is for a website.
I already have an OAuth2 package in Laravel on the server side (PHP) that takes care of authenticating the Facebook user, and pulls an access token. My question is, how do I pull this token and apply it to the Javascript SDK so I can have the FB.ui dialog appear as a modal? Do I even need to do this? Here is the javascript I am using:
window.fbAsyncInit = function () {
FB.init({ appId: '************', cookie: true, status: true, xfbml: true, oauth: true });
if (typeof facebookInit == 'function') {
facebookInit();
}
};
(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 facebookInit() {
FB.ui({
url : 'http://url.com',
method: 'feed',
name: 'Url',
link: url,
display: 'iframe',
picture: 'http://thisimage.png',
caption: fb_description,
}, function (response) {
if (response && response.post_id) {
window.location = "/artists";
} else {
window.location = "/artists";
}
});
}
I also had this issue - it turned out I didn't have the localhost
domain specified on my Facebook app settings. After I added it, it worked fine.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With