您好
,我已经在几个小时前下载了 LightOpenID (http://gitorious.org/lightopenid),但仍然不知道如何使其工作。
我把这个谷歌示例保存在test.php文件 中
<?php
require '../lib/init.php';
require '../lib/openID/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>';
?>
init.php 是我页面的初始化文件(常量、类、函数、数据库连接等)。
运行此代码后,我得到标签为“使用 Google 登录”的按钮,然后按下它
echo '<pre>'.print_r($openid,true).'</pre>';
提供有关 $openid 对象的一些信息
LightOpenID 对象 ( [returnUrl] => http://kur.com/openid.php [必需] => 数组 ()
[optional] => Array ( ) [identity:LightOpenID:private] => https://www.google.com/accounts/o8/id [claimed_id:LightOpenID:private] => https://www.google.com/accounts/o8/id [server:protected] => https://www.google.com/accounts/o8/ud [version:protected] => 2 [trustRoot:protected] => http://kur.com [aliases:protected] => [identifier_select:protected] => 1 [ax:protected] => 1 [sreg:protected] => [data:protected] => Array ( [login] => )
)
...没什么特别的...就是这样...
我花了很多时间在谷歌搜索教程,但甚至找不到。你能帮我么。
用户如何登录?
我必须从哪里获取登录的用户信息(如用户名、邮件)?
我从来没有使用过开放 ID,我很困惑....
在此先感谢