It's been quite a while since I have coded in PHP and I am running into difficulties looping through the returned response from an API. I am pretty comfortable in my PHP skills, but for some reason I keep getting caught up trying to loop through the following... Many of the returns from the API include several more layers of Objects, the example below is about the most simplistic return from the API.
I'm sure I'm just missing something easy and any help or example code simply looping through and echoing each result would be greatly appreciated!! Ideally I would like to be able to loop through both of the scenarios below.
I did a var_dump on the response and here is what I get:
array (size=1)
'Body' =>
object(stdClass)[6]
public 'userContext' =>
object(stdClass)[8]
public 'convCred' =>
object(stdClass)[10]
...
public 'valid' => boolean true
public 'isPasswordExpired' => boolean false
public 'cbId' => int 0083802121
public 'cnId' => int 1000545
public 'locale' => string 'en_US' (length=5)
public 'tncVersion' => int 2
public 'applicationId' => string 'ECFDA1FDBC00270772870CDC1786FFED' (length=32)
public 'cbConvCred' =>
object(stdClass)[9]
...
public 'preferenceInfo' =>
object(stdClass)[7]
...
public 'lastLoginTime' => int 1406729928
public 'loginCount' => int 282
public 'passwordRecovered' => boolean false
public 'emailAddress' => string 'abc@123.com' (length=11)
public 'loginName' => string 'TEST' (length=
public 'userId' => int 15932274
public 'userType' =>
object(stdClass)[14]
public 'userTypeId' => int 1
public 'userTypeName' => string 'normal_user' (length=11)
public 'isConfirmed' => boolean false
If I jsonencode and jsondecode the response this is what I get:
object(stdClass)[13]
public 'Body' =>
object(stdClass)[17]
public 'userContext' =>
object(stdClass)[18]
public 'convCred' =>
object(stdClass)[19]
...
public 'valid' => boolean true
public 'isPasswordExpired' => boolean false
public 'cbId' => int 0083802121
public 'cnId' => int 1000545
public 'locale' => string 'en_US' (length=5)
public 'tncVersion' => int 2
public 'applicationId' => string 'ECFDA1FDBC00270772870CDC1786FFED' (length=32)
public 'cbConvCred' =>
object(stdClass)[20]
...
public 'preferenceInfo' =>
object(stdClass)[21]
...
public 'lastLoginTime' => int 1406729953
public 'loginCount' => int 283
public 'passwordRecovered' => boolean false
public 'emailAddress' => string 'abc@123.com' (length=11)
public 'loginName' => string 'TEST' (length=
public 'userId' => int 15932274
public 'userType' =>
object(stdClass)[24]
public 'userTypeId' => int 1
public 'userTypeName' => string 'normal_user' (length=11)
public 'isConfirmed' => boolean false