ここで php-openid ライブラリをテストして学習しています: https://github.com/openid/php-openid
パッケージ全体をダウンロードし、examples/consumer をhttp://www.example.com/openidにアップロードし、Auth をhttp://www.example.com/Authにアップロードしました。
自分の openid の 1 つでテストしたところ、正しく動作しており、「You have successfully verifyed xxxxx as your identity.」と表示されます。
ただし、openid プロファイルに含まれる電子メールや名前などの SREG 属性は返されません。
コンシューマー サンプル ファイル (index.php、try_auth.php、finish_auth.php、common.php) のいずれにも変更を加えていないため、コードは次のようになります。
try_auth.php で:
$sreg_request = Auth_OpenID_SRegRequest::build(
// Required
array('nickname'),
// Optional
array('fullname', 'email'));
if ($sreg_request) {
$auth_request->addExtension($sreg_request);
}
finish_auth.php で:
$sreg = $sreg_resp->contents();
if (@$sreg['email']) {
$success .= " You also returned '".escape($sreg['email']).
"' as your email.";
}
if (@$sreg['nickname']) {
$success .= " Your nickname is '".escape($sreg['nickname']).
"'.";
}
if (@$sreg['fullname']) {
$success .= " Your fullname is '".escape($sreg['fullname']).
"'.";
}
私は試した:
$sreg = $sreg_resp->contents();
print_r($sreg);
しかし、それは空の配列であることが判明しました:
Array
(
)
私は試した:
- https://www.google.com/accounts/o8/id
- yahoo.com
- ichsie.myopenid.com
そして、最終的には $sreg の空の配列になります。
SREGではなくAXを使用するlightopenidを試しました:
- 連絡先メールアドレス
- お名前
そして、それらは値を正しく返しています。
では、php-openid ライブラリが必要な属性を返すようにするにはどうすればよいでしょうか?