Skip to content
Advertisement

Unable to get the user form kreait/firebase-php using $auth->getUser($uid);

I have my PHP code which looks like,

JavaScript

With the help of the above code, I am able to get the UID of the user but the output for the print_r($user) looks like,

JavaScript

How can I get print the $user in this format?

JavaScript

I need to get the email Id and other details of the user from using the function $auth->getUser(‘some-uid’); but I am unable to get the expected output with the above type of format, I am getting an object of the class as an output. Please refer: https://firebase-php.readthedocs.io/en/stable/user-management.html#user-records

Advertisement

Answer

you can get the output by using json_encode():

JavaScript

If you want to access the individual properties of the user record, you can use the UserRecord object directly and access (see https://github.com/kreait/firebase-php/blob/master/src/Firebase/Auth/UserRecord.php)

Please make sure to use the latest release of the SDK – the KreaitAuthUser object that your print_r() shows, doesn’t exist in the currently maintained 4.x releases, what should be returned is a UserRecord object.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement