I am getting response from SMS API call like below
stdClass Object (
[balance] => 3
[batch_id] => 289728321
[cost] => 2
[num_messages] => 2
[message] => stdClass Object (
[num_parts] => 1
[sender] => TXTLCL
[content] => This is test message from abc
)
[receipt_url] =>
[custom] =>
[messages] => Array (
[0] => stdClass Object (
[id] => 1172603746 [recipient] => 919796736174 )
[1] => stdClass Object (
[id] => 1172603747 [recipient] => 919858566712)
)
[status] => success
)
The code which I am trying to tweak is like below
if(count($this->capturedResponse) > 0)
{
foreach($this->capturedResponse as $response)
{
$balance = $response[0];
$batch_id = $response[1];
...
}
}
I am not able to separate the stdClass Object fields separately and put them in their corresponding variables.
Please Help !!!
The easiest way is to JSON-encode your object and then decode it back to an array: