-6

I am using login in with google, google returns below details once user authorised.

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 ( ) 
)

How i should read all the fields from above response it also have subarray.

Thank you in advance

Regards, Raj

user1978142
  • 7,946
  • 3
  • 17
  • 20
SmartDev
  • 481
  • 3
  • 11
  • 30

1 Answers1

1

If you have an object like this. Follow this example:

// 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

Supplemental Info: This topic is also tackled here

What is the "->" PHP operator called and how do you say it when reading code out loud?

Where do we use the object operator "->" in PHP?

Community
  • 1
  • 1
user1978142
  • 7,946
  • 3
  • 17
  • 20