1

我正在使用 LightOpenID,我正在尝试获取此 gmail 身份验证的属性,但它似乎没有在我的个人帐户上返回任何内容,并且我没有收到任何错误。我对 OpenID 很陌生,希望有人能帮助我找出以前做过这件事的人。

我正在指定字段validate()并返回它们process()

我正在使用 OpenID 网址:https ://www.google.com/accounts/o8/id

    public function show () {
        if ($this->site->tru->post->isRequest() || !$this->site->tru->get->isEmpty('openid_mode')) {
            require_once $this->site->tru->config->get('root.path').'/lib/php/openid.php';
            $this->lightOpenId = new LightOpenID;
            if ($this->validate() || $this->lightOpenId->validate()) {
                $this->process();
            }
        }

        $this->site->addCss('account/login.css');

        $this->site->addJs('account/login.js');

        echo $this->site->tru->display->getTemplate('/site/account/login.tpl');
    }

    public function process () {
        if ($this->lightOpenId->validate()) {
            echo '<pre>'.print_r($this->lightOpenId).'
'.print_r($this->lightOpenId->getAttributes()).'</pre>';
        }
    }

    public function validate () {
        if (!$this->site->tru->post->isEmpty('openid_url')) {
            $this->lightOpenId->identity = $this->site->tru->post->get('openid_url');
            $this->lightOpenId->optional = array('contact/email', 'namePerson', 'contact/postalCode/home', 'contact/country/home');

            header('Location: '.$this->lightOpenId->authUrl());
        }

        return count($this->error) == 0;
    }
4

2 回答 2

2
$openid->identity = 'https://www.google.com/accounts/o8/';

// use the following line to obtain the required details. These are the only details that google mail provides. This is for lightopenid.
$openid->required = array('namePerson/friendly', 'contact/email' , 'contact/country/home', 'namePerson/first', 'pref/language', 'namePerson/last'); 

header('Location: ' . $openid->authUrl());
于 2011-02-10T09:10:31.693 回答
1

Google 只回答必需的参数,完全忽略可选参数。

此外,它只能返回以下属性:

contact/country/home
contact/email
namePerson/first
namePerson/last
pref/language

所以namePerson并且contact/postalCode/home不会工作。

以上信息是谷歌特有的,与 LightOpenID 本身完全无关。

至于图书馆,我建议不要调用 $lightOpenId->validate() 两次。每次调用它时,它都会向可能拒绝第二个请求的提供者发送一个请求。

于 2010-11-17T00:06:17.033 回答