1

LightOpenID を使用しており、この Gmail 認証の属性を取得しようとしていますが、個人アカウントでは何も返されないようで、エラーも発生しません。私は OpenID に非常に慣れていないので、以前にこれを行ったことのある人が私を助けてくれることを望んでいました。

フィールドを指定して、validate()それらを返していますprocess()

OpenID URL を使用しています: 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

だからnamePersoncontact/postalCode/homeうまくいきません。

上記の情報は Google 固有のものであり、LightOpenID 自体とはまったく関係ありません。

ライブラリに関しては、$lightOpenId->validate() を 2 回呼び出さないことをお勧めします。呼び出すたびに、2 番目の要求を拒否する可能性があるプロバイダーに要求を送信します。

于 2010-11-17T00:06:17.033 に答える