CodeIgniter Forums
trying to access the message - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: External Resources (https://forum.codeigniter.com/forum-7.html)
+--- Forum: Addins (https://forum.codeigniter.com/forum-13.html)
+--- Thread: trying to access the message (/thread-78250.html)



trying to access the message - richb201 - 12-22-2020

This is the object returned from the fusionAuth library. I am getting it in a variable called $result. 

Code:
FusionAuth\ClientResponse Object
(
    [errorResponse] => stdClass Object
        (
            [fieldErrors] => stdClass Object
                (
                    [user.email] => Array
                        (
                            [0] => stdClass Object
                                (
                                    [code] => [duplicate]user.email
                                    [message] => A User with email [[email protected]] already exists.
                                )

                        )

                )

        )

  I am trying to print out the message. I have tried this echo($result->errorResponse->fieldErrors->user.email[message]); and every other way I could think of. 
 I an getting: Message: Undefined property: stdClass::$user
What is the proper way to echo out the message field?


RE: trying to access the message - includebeer - 12-22-2020

@richb201, I move your message in the Addins category. It didn't belong in Choosing CodeIgniter. I also edited your post to add CODE tags because it was unreadable. Please be careful in what category you post and add code tags when you copy php code.

For your question, I think this would be the right way to echo the message:
PHP Code:
echo($result->errorResponse->fieldErrors->user.email[0]->message);