o0'*_*0'. 5 php openid oauth lightopenid
我很困惑.
我能够使用LightOpenID使openid登录有点工作.
我所做的就是openid_identity" https://www.google.com/accounts/o8/id?id=xxx".非常令人失望:我也希望得到这个电子邮件地址.
即我需要登录(这是openid所做的)并知道用户用来登录的谷歌帐户的电子邮件地址.
有功能,$openid->getAttributes()但我得到的只是一个空数组:我猜谷歌不会给我任何其他东西openid_identity.
所以我猜我应该用OAuth,对吧?我对此毫无头绪.我只发现了可怕的和困惑的文件,要么假装解释一切(我做的意思是一切),或者不解释任何东西 都.
是的,当然我已经尝试查看之前的帖子,就像我在google上搜索一样.请再读一遍上一段.
Ali*_*xel 10
我刚刚发现了LightOpenID,我觉得它太棒了.我已设法使用以下修改获取电子邮件地址,名字和姓氏以及首选语言example-gmail.php:
<?php
require_once('openid.php');
if (empty($_GET['openid_mode']))
{
    if (isset($_GET['login']))
    {
        $openid = new LightOpenID();
        $openid->identity = 'https://www.google.com/accounts/o8/id';
        $openid->required = array('namePerson/first', 'namePerson/last', 'contact/email', 'pref/language');
        header('Location: ' . $openid->authUrl());
        //header('Location: ' . str_replace('&', '&', $openid->authUrl()));
    }
    else
    {
        echo '<form action="?login" method="post">' . "\n";
        echo '<button>Login with Google</button>' . "\n";
        echo '</form>' . "\n";
    }
}
else if ($_GET['openid_mode'] == 'cancel')
{
    echo 'User has canceled authentication!';
}
else
{
    $openid = new LightOpenID();
    echo 'User ' . ($openid->validate() ? $_GET['openid_identity'] . ' has ' : 'has not ') . 'logged in.';
    echo '<pre>';
    print_r($openid->getAttributes());
    echo '</pre>';
}
?>
Run Code Online (Sandbox Code Playgroud)
我更改了代码以使其更具可读性,输出:
User https://www.google.com/accounts/o8/id?id=*** has logged in.
Array
(
    [namePerson/first] => Alix
    [contact/email] => ***@gmail.com
    [pref/language] => en
    [namePerson/last] => Axel
)
Run Code Online (Sandbox Code Playgroud)
我仍然无法从谷歌获得邮政编码和其他人,但我在myOpenID.com上取得了成功.
|   归档时间:  |  
           
  |  
        
|   查看次数:  |  
           2956 次  |  
        
|   最近记录:  |