Bireon
Bireon

Reputation: 189

Print specific SOAP response

I have the soap response from the client side using:

Array (
 [return] => Array (
 [responseCode] => 200 [responseMessage] => SUCCESS [subscriberProfile] => Array (
 [entry] => Array ( 
 [0] => Array ( [key] => SUBSCRIBER_IDENTITY [value] => 1234567890 ) ) ) ) ) 

and the php code to print it:

Response Code: <?php echo $profile->return->responseCode; ?> - <?php echo $profile->return->responseMessage; ?><br />
Identity: <?php echo $profile->return->subscriberProfile->entry->SUBSCRIBER_IDENTITY; ?></br />

The response code printed on the browser, but not for identity. Any idea why? I think is path not called correctly

also tried something like: <?php echo $profile->return->responseCode->subscriberProfile->entry[0]->SUBSCRIBER_IDENTITY; ?></br />

Thanks,

Upvotes: 0

Views: 57

Answers (1)

Nick
Nick

Reputation: 147196

Because your entry value is an array of objects containing key/value pairs, you have to find the right key to be able to output its value. Try something like this:

foreach ($response->return->subscriberProfile->entry as $entry) {
    if ($entry->key == 'SUBSCRIBER_IDENTITY') echo $entry->value;
}

Output:

1234567890

Demo on 3v4l.org

Upvotes: 3

Related Questions