0

Google auth services return a php object (Lets call it $Ticket). It's value is this

Google_LoginTicket Object ( [envelope:Google_LoginTicket:private] => Array ( [alg] => RS256 [kid] => 057d4167ee9b75e7b3a3fcc9c1ca17a14dab5044 ) )

Now i want to access the value of alg, that is "RS256".

print_r ($Ticket->{'envelope:Google_LoginTicket:private'});

print_r doesn't give anything.

2
  • Have you tried doing print_r($Ticket)? Add the output to your question Commented Feb 26, 2013 at 13:55
  • @adam He posted it's value?! Commented Feb 26, 2013 at 13:55

3 Answers 3

2

Google_LoginTicket have getAttributes() function, which return array of attributes, you can check this, in source code https://github.com/sylvainw/GPlusGlobe/blob/master/src/auth/Google_LoginTicket.php

$attrs = $Ticket->getAttributes();
print_r($attrs["envelope"]);
Sign up to request clarification or add additional context in comments.

2 Comments

I would add, that Google_LoginTicket is private, so you can't directly access it. And it is bad habit to make any attribute public. One should always try to use getters/setters.
"envelope" is private ;) Google_LoginTicket is the class name
0

You can access private properties through reflection. However, it is not recommended. These are mostly features used by frameworks.

Instead, you should search for methods providing you with the value you are looking for.

var_dump(get_class_methods($Ticket));

Typically, reading the API documentation or the source file directly will allow you to see the methods available on the class.

Comments

0

The envelope instance variable is private, so you can't just access it like that; you have to work with the methods that are provided:

$attributes = $Ticket->getAttributes();

$envelope = $attributes['envelope'];

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.