I'm making a form for sending SMS, but I'm not able to handle the feedback to get the program going.
I want to do a SE conditional for every return that is passed.
I've tried using the curl to make this condition, as per the code below:
<?php
$matricula = $_GET['matricula'];
if (isset($_POST['acao']) && $_POST['acao'] == "enviartorpedo") {
$email = $email;
$numero = $numero;
$codigo = intval($cpf/2000000);
$ch = curl_init();
$data = array('key' => 'XXXXXXXXXXXXXX',
'type' => '9',
'number' => $_POST['numero'],
'msg' => 'Rensz: Seu código para cadastro: '.$codigo,
);
curl_setopt($ch, CURLOPT_URL, 'http://api.smsempresa.com.br/send');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$res = curl_exec($ch);
$err = curl_errno($ch);
$errmsg = curl_error($ch);
$header = curl_getinfo($ch);
curl_close($ch);
if ($res == "SEM NUMERO DESTINATARIO.") {
echo "Deu certo";
} else {
echo "Nada aconteceu";
}
}
?>
But it did not work, even putting the message equal to what $RES
showed on the screen the SE conditional rule was not respected.
Following to solve the problem I thought about handling the information that comes back from the xml , but I do not know how to get the information separate.
The XML return is this:
<?xml version="1.0"?>
<smsempresa>
<retorno situacao="OK" codigo="1" id="601440663">MENSAGEM NA FILA</retorno>
</smsempresa>
How can I get this return, transform the information that is inside the "Code", to create the SE condition and then terminate the code.
Does anyone know how to handle this response?