如何在PHP中读取google返回的数据对象

我使用google登录,一旦用户授权,google会返回以下详细信息。

Google_Service_Oauth2_Userinfoplus Object ( 
    [email] => mona123.janorkar@gmail.com 
    [familyName] => Janorkar 
    [gender] => 
    [givenName] => Mona 
    [hd] => 
    [id] => 11018813453254107047543 
    [name] => Mona Janorkar 
    [verifiedEmail] => 1 
    [data:protected] => Array ( 
    [verified_email] => 1 
    [given_name] => Mona 
    [family_name] => Janorkar ) 
    [processed:protected] => Array ( ) 
)

我应该如何阅读从上面的所有领域响应它也有子阵列。

先谢谢你

问候,拉杰


如果你有这样的对象。 遵循这个例子:

// THIS IS A SAMPLE, JUST TO SIMULATE how to access values inside
class Google_Service_Oauth2_Userinfoplus {
    public $email = 'mona123.janorkar@gmail.com';
    public $familyName = 'Janorkar';
    public $gender = null;
    public $givenName = 'Mona';
    public $hd = null;
    public $id = '11018813453254107047543';
    public $name = 'Mona Janorkar';
    public $verifiedEmail = 1;
    protected $data = array(
        'verified_email' => 1,
        'given_name' => 'Mona',
        'family_name' => 'Janorkar',

    );
    protected $processed = array();
}

// for example! this is the returned object
$object = new Google_Service_Oauth2_Userinfoplus();

// you can access the properties of the object thru the "->"
echo $object->email; // mona123.janorkar@gmail.com

补充信息:此主题也在这里解决

什么是“ - >”PHP运算符,当你大声朗读代码时,你怎么说?

我们在PHP中使用对象运算符“ - >”在哪里?

链接地址: http://www.djcxy.com/p/58153.html

上一篇: How to read google returned data object in PHP

下一篇: why would there be more than one object operator in a line of code in php?