LightOpenIDを発見したばかりで、素晴らしいと思います。の次の変更を使用して、電子メールアドレス、姓名、優先言語を取得できましたexample-gmail.php
。
<?php
require_once('openid.php');
if (empty($_GET['openid_mode']))
{
if (isset($_GET['login']))
{
$openid = new LightOpenID();
$openid->identity = 'https://www.google.com/accounts/o8/id';
$openid->required = array('namePerson/first', 'namePerson/last', 'contact/email', 'pref/language');
header('Location: ' . $openid->authUrl());
//header('Location: ' . str_replace('&', '&', $openid->authUrl()));
}
else
{
echo '<form action="?login" method="post">' . "\n";
echo '<button>Login with Google</button>' . "\n";
echo '</form>' . "\n";
}
}
else if ($_GET['openid_mode'] == 'cancel')
{
echo 'User has canceled authentication!';
}
else
{
$openid = new LightOpenID();
echo 'User ' . ($openid->validate() ? $_GET['openid_identity'] . ' has ' : 'has not ') . 'logged in.';
echo '<pre>';
print_r($openid->getAttributes());
echo '</pre>';
}
?>
コードを変更して、もう少し読みやすくしました。出力は次のとおりです。
User https://www.google.com/accounts/o8/id?id=*** has logged in.
Array
(
[namePerson/first] => Alix
[contact/email] => ***@gmail.com
[pref/language] => en
[namePerson/last] => Axel
)
私はまだ郵便番号などを Google から取得できませんが、myOpenID.comで成功しました。