成功登录后,我正在尝试将我的页面重定向到新的 url..
<?php
include_once "fbmain.php";
$config['baseurl'] = "http://localhost:8080/index.php";;
// login or logout url will be needed depending on current user state.
if ($fbme) {
$logoutUrl = $facebook->getLogoutUrl(
array(
'next' => $config['baseurl'],
)
);
} else {
$loginUrl = $facebook->getLoginUrl(
array(
'display' => 'popup',
'next' => $config['baseurl'] . '?loginsucc=1',
'cancel_url'=> $config['baseurl'] . '?cancel=1',
'req_perms' => 'email,user_birthday',
)
);
}
// if user click cancel in the popup window
if (isset($_REQUEST['cancel'])){
echo "<script>
window.close();
</script>";
}
if ($fbme && isset($_REQUEST['loginsucc'])){
//only if valid session found and loginsucc is set
//after facebook redirects it will send a session parameter as a json value
//now decode them, make them array and sort based on keys
$sortArray = get_object_vars(json_decode($_GET['session']));
ksort($sortArray);
$strCookie = "";
$flag = false;
foreach($sortArray as $key=>$item){
if ($flag) $strCookie .= '&';
$strCookie .= $key . '=' . $item;
$flag = true;
}
//now set the cookie so that next time user don't need to click login again
setCookie('fbs_' . "{$fbconfig['appid']}", $strCookie);
echo "<script>
window.close();
window.opener.location.reload();
</script>";
}
//if user is logged in and session is valid.
if ($fbme){
header("Location: http://localhost:8080/main.php");
exit;
}
?>
但是,它会在窗口登录弹出框内加载页面,这是为什么以及如何加载它以使其位于主页中。