php-openid库没有返回SREG属性?

时间:2013-06-03 04:43:50

标签: php openid

我正在这里测试和学习php-openid库:https://github.com/openid/php-openid

我下载了整个软件包并将示例/消费者上传到http://www.example.com/openid,并将Auth上传到http://www.example.com/Auth,因为我的网站只需要成为依赖方。

当我使用其中一个openids进行测试时,它正常工作,并显示“您已成功验证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的空数组结束。

我尝试使用AX而不是SREG的lightopenid:

  • 接触/电子邮件
  • namePerson

他们正确地返回了值。

那么如何让php-openid库返回我需要的属性呢?

1 个答案:

答案 0 :(得分:0)

提供者是否实际返回了SREG属性?您从try_auth.php发送的HTTP响应是什么?您在finish_auth.php上收到的HTTP请求是什么?

相关问题