我创建了一个用户使用 google 登录的站点,其中打开一个弹出窗口进行登录,当用户单击提交按钮时,弹出窗口关闭 & 用户重定向到另一个页面。
我已经完成了代码,但它在 FF bt 中工作正常,在 chrome 中不工作
这是我的代码,任何人都可以建议我需要做哪些更改,以便它也可以在 chrome 中使用。
<?php
@session_start();
require 'openid.php';
try {
$openid = new LightOpenID;
if(!$openid->mode) {
if(isset($_GET['login'])) {
$openid->identity = 'https://www.google.com/accounts/o8/id';
$openid->required = array('namePerson/first', 'namePerson/last', 'contact/email');
// @header('Location: ' . $openid->authUrl());
echo "<script>location.href='".$openid->authUrl()."'</script>";
}
} elseif($openid->mode == 'cancel') {
echo 'User has canceled authentication!';
} else {
if($openid->validate())
{
'User <b>' . $openid->identity . '</b> has logged in.<br>';
"<h3>User information</h3>";
$_SESSION['identity'] = $openid->identity;
$identity = $openid->identity;
$attributes = $openid->getAttributes();
$_SESSION['email'] = $attributes['contact/email'];
$_SESSION['first_name'] = $attributes['namePerson/first'];
$_SESSION['last_name'] = $attributes['namePerson/last'];
/* "mode: " . $openid->mode . "<br>";
"identity: " . $identity . "<br>";
"email: " . $email . "<br>";
"first_name: " . $first_name . "<br>";
"last_name: " . $last_name . "<br>";*/
}
else
{
echo 'User ' . $openid->identity . 'has not logged in.';
}
echo "<script>window.close();</script>";
echo '<script>window.opener.location.href="index2.php"</script>';
}
} catch(ErrorException $e) {
echo $e->getMessage();
}
?>