The google identity toolkit PHP Quick Start app provides the following block of code that displays some information about the user once they have successfully logged in.
<?php if ($gitkitUser) { ?>
Welcome back!<br><br>
Email: <?= $gitkitUser->getEmail() ?><br>
Id: <?= $gitkitUser->getUserId() ?><br>
Name: <?= $gitkitUser->getDisplayName() ?><br>
Identity provider: <?= $gitkitUser->getProviderId() ?><br>
<?php } else { ?>
You are not logged in yet.
<?php } ?>
The output on the page looks like this:
Email: someuser@hotmail.com
Id: 123
Name: Bob User
Identity provider: facebook.com
I would like to display the user's avatar/photo as well but can not seem to sort out how to do this. I've tried $gitkitUser->getPhotoUrl();
but that seems to return nothing and I can't find any good documentation.
If I print_r
the $gitkitUser
object I can see there is indeed a photoUrl
and the URL is correct but it's set to private and I can't seem to access it:
Gitkit_Account Object(
[localId: Gitkit_Account: private] => 123
[email: Gitkit_Account: private] => someuser@hotmail.com
[providerId: Gitkit_Account: private] => facebook.com
[providerInfo: Gitkit_Account: private] => Array([0] => Array(
[providerId] => facebook.com
[displayName] => Bob User
[photoUrl] => https: //scontent.xx.fbcdn.net/.....
[federatedId] => http://facebook.com/123 )
)
[displayName:Gitkit_Account:private] => Bob User
[photoUrl:Gitkit_Account:private] =>
[emailVerified:Gitkit_Account:private] =>
[passwordHash:Gitkit_Account:private] =>
[salt:Gitkit_Account:private] =>
)
Any ideas as to how I can get access to the user's image to display on the page?