我正在这里测试和学习php-openid库:https://github.com/openid/php-openid
我下载了整个软件包,并将示例/消费者上传到http://www.example.com/openid,还将8月上传到http://www.example.com/Auth,因为我的网站只需要成为依赖方。
当我用一个openid测试它时,它工作正常,它显示“您已经成功地验证了xxxxx作为您的身份”。
但是,它不返回任何SREG属性,如电子邮件或名称,而我的openid配置文件确实包含这些信息。
我没有对任何消费者示例文件(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
(
)我试过:
最后是一个空的$sreg数组。
我尝试了lightopenid,它使用AX而不是SREG:
他们正确地返回了这些值。
那么,如何使php-openid库返回我需要的属性呢?
发布于 2013-06-06 14:38:59
提供者是否实际返回SREG属性?您从try_auth.php发送的HTTP响应是什么?您在finish_auth.php上收到的HTTP请求是什么?
https://stackoverflow.com/questions/16890105
复制相似问题