【问题标题】:Attributes exchange using Net::OpenID::Consumer使用 Net::OpenID::Consumer 进行属性交换
【发布时间】:2013-05-13 12:20:03
【问题描述】:
my $csr = Net::OpenID::Consumer->new(
    ua              => LWP::UserAgent->new,
    consumer_secret => '123456xXx',
    required_root   => "http://www.myopenidsample.net/",
  );

my $openid = "https://me.yahoo.com";

my $claimed_id = $csr->claimed_identity($openid);

if ($claimed_id){
    my $check_url = $claimed_id->check_url(
        delayed_return => 1,
        return_to      => "http://www.myopenidsample.net/response.cgi",
        trust_root     => "http://www.myopenidsample.net/",
      );

    print $q->redirect($check_url);
}

如何获取电子邮件、名字、姓氏和国家/地区等属性? 如何将以下参数附加到 URL?

openid.ext1.mode fetch_request
openid.ext1.必填国家、电子邮件、名字、姓氏、语言
openid.ext1.type.country http://axschema.org/contact/country/home
openid.ext1.type.email http://axschema.org/contact/email
openid.ext1.type.firstname http://axschema.org/namePerson/first
openid.ext1.type.language http://axschema.org/pref/language
openid.ext1.type.lastname http://axschema.org/namePerson/
openid.ns.ext1 http://openid.net/srv/ax/1.0

【问题讨论】:

    标签: perl openid perl-module mod-perl2


    【解决方案1】:

    您需要在调用 check_url 之前添加以下代码(该示例已通过 Google 测试,以便仅获取电子邮件):

        $claimed_id->set_extension_args(
        "http://openid.net/srv/ax/1.0",
          {
            'mode' => 'fetch_request',
            'type.email' => 'http://axschema.org/contact/email',
            'required'   => 'email',
          });
    

    为了在返回中取回值,我使用:

        my $email = $csr->message->get_ext
             ("http://openid.net/srv/ax/1.0", "value.email");
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-11-06
      • 2013-06-28
      • 1970-01-01
      • 2013-08-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多