【问题标题】:php-openid library not returning SREG attributes?php-openid 库不返回 SREG 属性?
【发布时间】:2013-06-03 04:43:50
【问题描述】:

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

我下载了整个包并将examples/consumer上传到http://www.example.com/openid,还将Auth上传到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 的空数组结束。

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

  • 联系方式/电子邮件
  • 姓名人

他们正确地返回了值。

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

【问题讨论】:

    标签: php openid


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-07-16
      • 2014-06-04
      • 1970-01-01
      • 2018-03-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多