如何从用户单击 Facebook 的登录按钮重定向到同一页面,我的代码在主页上运行正常,如果用户从 diff 页面单击则存在问题,它重定向到主页,而不是该页面。
如何解决?
// javascript sdk
<?php
if(!$fbuser){
$fbuser = null;
$loginUrl = $facebook->getLoginUrl(array('redirect_uri'=>$homeurl,'scope'=>$fbPermissions));
echo '<a href='.$loginUrl.' class="btn btn-default facebook"> <i class="fa fa-facebook modal-icons"></i> Sign In with Facebook </a>';
}else{
$user_profile = $facebook->api('/me?fields=id,first_name,last_name,email,gender,locale,picture');
$user = new FB_users();
$user_data = $user->checkUser('facebook',$user_profile['id'],$user_profile['first_name'],$user_profile['last_name'],$user_profile['email'],$user_profile['gender'],$user_profile['locale'],$user_profile['picture']['data']['url']);
// Add email in session & reload page
// i have used javascript sdk in my page.
$_SESSION['email'] = $user_profile['email'];
echo '<script>parent.window.location.reload(true);</script>';
}
?>
=====that my code on login page=========
so how to do it .
最佳答案
试试这个
<?php
if(!$fbuser) {
$fbuser = null;
$loginUrl = $facebook->getLoginUrl(array('redirect_uri'=>$homeurl,'scope'=>$fbPermissions));
echo '<a href='.$loginUrl.' class="btn btn-default facebook"> <i class="fa fa-facebook modal-icons"></i> Sign In with Facebook </a>';
} else {
$user_profile = $facebook->api('/me?fields=id,first_name,last_name,email,gender,locale,picture');
$user = new FB_users();
$user_data = $user->checkUser('facebook',$user_profile['id'],$user_profile['first_name'],$user_profile['last_name'],$user_profile['email'],$user_profile['gender'],$user_profile['locale'],$user_profile['picture']['data']['url']);
// Add email in session & reload page
// i have used javascript sdk in my page.
$_SESSION['email'] = $user_profile['email'];
// do not place HTML before this line
// filter $_SERVER['HTTP_REFERER'] for your security
header('Location: ' . $_SERVER['HTTP_REFERER']);
}
?>
关于javascript - 我如何从用户点击 facebook 的登录按钮重定向到同一页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37741321/