Facebook的PHP API登录窗口弹出 [英] Facebook PHP API login window popup
问题描述
我使用的最新的Facebook的PHP API的SDK版本。我试图让登录按钮激活,而不是打开完整的页面弹出。我尝试使用本教程:<一href=\"http://thinkdiff.net/facebook/create-facebook-popup-authentication-window-using-php-and-javascript/\">http://thinkdiff.net/facebook/create-facebook-popup-authentication-window-using-php-and-javascript/
弹出的工作,但是当我登录,而不是弹出窗口关闭,该网站刚刚开通的弹出窗口中。
有谁知道我需要做,使弹出的窗口关闭,一旦我已经登录?
下面是我的PHP code用于生成登录网址:
&LT; PHP
$ loginUrl = $ me_on_facebook-&GT; getLoginUrl(阵列(
'显示'=&GT; '弹出',
'下一个'=&GT; $配置['baseURL时'],
REDIRECT_URI'=&GT; $配置['baseURL时'],
范围=&GT; '电子邮件'
));
?&GT;
在弹出的登录框加载和/用户连接迹象,框,然后装入用?code网站= XXX附加到URL。所以对于网站我加了一个PHP if语句
&LT; PHP
如果(使用isset($ _ REQUEST ['状态'])及和放大器;使用isset($ _ REQUEST ['code'])){
回声&LT;脚本&GT;
window.close()的;
window.opener.location.reload();
&所述; /脚本&gt;中;
}其他{
//加载页面
}
?&GT;
这样做是关闭弹出和重装发起弹出原来的页面。
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.
这篇关于Facebook的PHP API登录窗口弹出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!