我是开放 id 的新手,但我仍然尝试将开放 id 集成到我的网站中。我使用雅虎提供商登录到我的网站。可以帮助我获取用户信息,如雅虎邮件 ID、名字、姓氏。
我从为 google 提供的网站上获取了以下代码,我已将提供程序更改为 yahoo
我尝试过的代码:
<?php
# Logging in with Google accounts requires setting special identity, so this example shows how to do it.
require 'openid.php';
try {
# Change 'localhost' to your domain name.
$openid = new LightOpenID('localhost');
if(!$openid->mode) {
if(isset($_GET['login'])) {
$openid->identity = 'https://me.yahoo.com';
header('Location: ' . $openid->authUrl());
}
?>
<form action="?login" method="post">
<button>Login with Yahoo</button>
</form>
<?php
} elseif($openid->mode == 'cancel') {
echo 'User has canceled authentication!';
} else {
echo 'User ' . ($openid->validate() ? $openid->identity . ' has ' : 'has not ') . 'logged in.';
print_r($openid->ax_to_sreg);
}
} catch(ErrorException $e) {
echo $e->getMessage();
}
登录后,我会像这样退出:
User https://open.login.yahooapis.com/openidx20/user_profile/XXXX has logged in.
上面的网址有什么用?如何获取用户信息?