Read answer multidimensional array API smsgateway.me

1

I am testing the sms sending of link

I am able to send the message correctly, what I do not know is how to correctly read the response of the array that results I get this answer Success:

Array ( [response] => Array ( [success] => 1 [result] => Array ( [success] => Array ( [0] => Array ( [id] => 24221330 [device_id] => 30006 [message] => Hello World 5! [status] => pending [send_at] => 1474902591 [queued_at] => 0 [sent_at] => 0 [delivered_at] => 0 [expires_at] => 1474906131 [canceled_at] => 0 [failed_at] => 0 [received_at] => 0 [error] => [created_at] => 1474902553 [contact] => Array ( [id] => 5226653 [name] => Noel [number] => +54412512554 ) ) ) [fails] => Array ( ) ) ) [status] => 200 ) 

I would like to validate if the sent was sent correctly but I do not know how to access the array to see if it was sent.

This is the answer when it is unsuccessful:

Array ( [response] => Array ( [success] => 1 [result] => Array ( [success] => Array ( ) [fails] => Array ( [0] => Array ( [number] => +544782548 [message] => Hello World 5! [device] => 30005 [send_at] => 1474915203 [expires_at] => 1474918743 [email] => [email protected] [password] => aaaa [errors] => Array ( [device] => Array ( [0] => The selected device is invalid. ) ) ) ) ) ) [status] => 200 ) 
    
asked by Jesus7878 26.09.2016 в 22:25
source

1 answer

0

Yes, good idea. It is as follows:

if (!isset($result['response']['result']['fails']['0'])) { echo "exito";} 
else { 
$error='Ocurrio un Error'; 
if (isset($result['response']['result']['fails']['0']['errors']‌​['device']['0'])) $error.=$result['response']['result']['fails']['0']['errors']‌​['device']['0'];  echo $error;}
    
answered by 28.09.2016 в 14:15