使用LightOpenID类,我试图将 Google 的登录信息与我的网站集成。我正在使用默认代码:
<?php
require 'includes/openid.php';
try {
if(!isset($_GET['openid_mode'])) {
if(isset($_GET['login'])) {
$openid = new LightOpenID;
$openid->identity = 'https://www.google.com/accounts/o8/id';
header('Location: ' . $openid->authUrl());
}
?>
<form action="?login" method="post">
<button>Login with Google</button>
</form>
<?php
} elseif($_GET['openid_mode'] == 'cancel') {
echo 'User has canceled authentication!';
} else {
$openid = new LightOpenID;
echo 'User ' . ($openid->validate() ? $openid->identity . ' has ' : 'has not ') . 'logged in.';
}
} catch(ErrorException $e) {
echo $e->getMessage();
}
echo '<pre>'.print_r($openid,true).'</pre>';
?>
最初,这告诉我我缺少构造方法的参数 1,迫使我将该new LightOpenID
方法称为new LightOpenID($host)
. 但是由于我已经更改了它并尝试登录,所以当我恢复代码时它没有给出那个错误只是去抓住错误......
无论如何,撇开这一点不谈,在我添加主机后,我被带到了谷歌页面,它询问我是否想用我的谷歌帐户登录该网站。我按下了登录按钮,然后被收回,却被告知我没有登录。
User has not logged in.
LightOpenID Object
(
[returnUrl] => myReturnURL
[required] => Array
(
)
[optional] => Array
(
)
[verify_peer] =>
[capath] =>
[cainfo] =>
[data] => Array
(
[login] =>
[openid_ns] => http://specs.openid.net/auth/2.0
[openid_mode] => id_res
[openid_op_endpoint] => https://www.google.com/accounts/o8/ud
[openid_response_nonce] => 2012-07-23T14:06:24ZQwlS1zWFRdvg6A
[openid_return_to] => myReturnURL
[openid_assoc_handle] => AMlYA9WMwp_rTkH3swNLEF5UASFvhyOR-kqVSXGe7cvXe7ws5z8HHWUu
[openid_signed] => op_endpoint,claimed_id,identity,return_to,response_nonce,assoc_handle
[openid_sig] => NtOEY8dUM1Hpt2tTR9x0RdN5o1c=
[openid_identity] => https://www.google.com/accounts/o8/id?id=AItOawkXNCi5qq-3Vj_esgSQAwmEN_nVIC8BHAQ
[openid_claimed_id] => https://www.google.com/accounts/o8/id?id=AItOawkXNCi5qq-3Vj_esgSQAwmEN_nVIC8BHAQ
)
[identity:LightOpenID:private] =>
[claimed_id:LightOpenID:private] => https://www.google.com/accounts/o8/id?id=AItOawkXNCi5qq-3Vj_esgSQAwmEN_nVIC8BHAQ
[server:protected] => https://www.google.com/accounts/o8/ud
[version:protected] => 2
[trustRoot:protected] => mySite
[aliases:protected] =>
[identifier_select:protected] =>
[ax:protected] => 1
[sreg:protected] =>
[setup_url:protected] =>
[headers:protected] => Array
(
[cache-control] => no-cache, no-store, max-age=0, must-revalidate
[pragma] => no-cache
[expires] => Fri, 01 Jan 1990 00:00:00 GMT
[date] => Mon, 23 Jul 2012 14:06:26 GMT
[content-type] => text/plain; charset=UTF-8
[x-content-type-options] => nosniff
[x-frame-options] => SAMEORIGIN
[x-xss-protection] => 1; mode=block
[server] => GSE
)
)
我已经登录了谷歌,所以谷歌页面没有要求我登录,只是为了验证我想使用我的谷歌帐户登录我自己的网站。有没有人看到它没有说我已登录的原因?
提前致谢。