I'm using using the most recent version of facebook's php api sdk. I'm trying to make the login button activate a popup instead of opening the full page. I tried using this tutorial: http://thinkdiff.net/facebook/create-facebook-popup-authentication-window-using-php-and-javascript/
The popup worked but when I logged in, instead of the popup window closing, the website just opened inside the popup.
Does anybody know what I need to do to make the popup window close once I have logged in?
Here is my php code for generating the login url:
<?php
$loginUrl = $me_on_facebook->getLoginUrl(array(
'display' => 'popup',
'next' => $config['baseurl'],
'redirect_uri' => $config['baseurl'],
'scope' => 'email'
));
?>
When the popup login box loads and the user signs in/connects, the box then loads the site with ?code=XXX appended to the url. So for the site I added a php if statement
<?php
if (isset($_REQUEST['state']) && isset($_REQUEST['code'])) {
echo "<script>
window.close();
window.opener.location.reload();
</script>";
} else {
// load page
}
?>
What this does is close the popup and reload the original page that initiated the popup.
You should use Facebook Javascript SDK and authorize user using Javascript function FB.login(). Tutorial is here http://developers.facebook.com/docs/reference/javascript/FB.login/
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