我想让我的 facebook api 登录弹出窗口在用户登录后关闭,在用户单击带有 facebook 图像的登录后,弹出窗口成功打开,在用户登录弹出窗口后,弹出窗口仍然存在并重定向到我成功登录的网站但是,我希望在用户成功登录后关闭弹出窗口,并将父登录页面重定向到主页。
谢谢你,
这是我所做的:
Javascript 的:
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : '<?php echo $_setting['facebook_api']; ?>',
channelUrl : '//<?php echo $website; ?>/channel.html',
status : true,
cookie : true,
xfbml : true
});
};
(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));
</script>
<script type="text/javascript">
function popup(url)
{
var width = 600;
var height = 400;
var left = (screen.width - width)/2;
var top = (screen.height - height)/2;
var params = 'width='+width+', height='+height;
params += ', top='+top+', left='+left;
params += ', directories=no';
params += ', location=no';
params += ', menubar=no';
params += ', resizable=no';
params += ', scrollbars=no';
params += ', status=no';
params += ', toolbar=no';
newwin=window.open(url,'FB', params);
opener.location.reload();
if (window.focus) {newwin.focus()}
return false;
}
</script>
用户登录部分:
<a href="javascript:void(0)"
onclick="popup('https://www.facebook.com/dialog/oauth?client_id=<?php echo $_setting['facebook_api']; ?>
&redirect_uri=<?php echo urlencode($website."/index.php"); ?>
&cancel_url=<?php echo urlencode($website."/register"); ?>
&scope=email')">
<img src="<?php echo $website; ?>/images/fb.png" /></a>