Php 谷歌登录集成

Php 谷歌登录集成,php,login,Php,Login,我对社交网络登录API非常陌生。现在我在谷歌登录集成工作 我使用openid示例类进行了测试,得到如下结果: 如何从中获取值(用户信息、好友列表等) 我需要为此创建任何谷歌应用程序吗 你能帮我整合一下吗 谢谢你关注这个 您可以非常轻松地使用访问用户信息。您可以非常轻松地访问AX/SREG扩展 > AX and SREG extensions are supported. * To use them, specify > $openid->required and/or $o

我对社交网络登录API非常陌生。现在我在谷歌登录集成工作

我使用openid示例类进行了测试,得到如下结果:

如何从中获取值(用户信息、好友列表等)

我需要为此创建任何谷歌应用程序吗

你能帮我整合一下吗


谢谢你关注这个

您可以非常轻松地使用访问用户信息。您可以非常轻松地访问AX/SREG扩展

> AX and SREG extensions are supported.  * To use them, specify
> $openid->required and/or $openid->optional before calling
> $openid->authUrl().  * These are arrays, with values being AX schema
> paths (the 'path' part of the URL).  * For example:  *  
> $openid->required = array('namePerson/friendly', 'contact/email');  * 
> $openid->optional = array('namePerson/first');  * If the server
> supports only SREG or OpenID 1.1, these are automaticaly  * mapped to
> SREG names, so that user doesn't have to know anything about the
> server.
> To get the values, use $openid->getAttributes().


使用谷歌登录
<?php

# Logging in with Google accounts requires setting special identity, so this example shows how to do it.
require 'openid.php';
try {
    $openid = new LightOpenID;
    $openid->required = array('namePerson/friendly', 'contact/email');
    $openid->optional = array('namePerson/first');

    if(!$openid->mode) {
        if(isset($_GET['login'])) {
            $openid->identity = 'https://www.google.com/accounts/o8/id';
            header('Location: ' . $openid->authUrl());
        }
?>
<form action="?login" method="post">
    <button>Login with Google</button>
</form>
<?php
    } elseif($openid->mode == 'cancel') {
        echo 'User has canceled authentication!';
    } else {
        echo 'User ' . ($openid->validate() ? $openid->identity . ' has ' : 'has not ') . 'logged in.';
        echo "<p>";
        print_r($openid->getAttributes());
        echo "</p>";
    }
} catch(ErrorException $e) {
    echo $e->getMessage();
}


` print_r($openid->getAttributes());` shows email name which was required because `$openid->required = array('namePerson/friendly', 'contact/email');` I wonder why friendly is not shown, but I don't even think I set one for gmail.