Commit df0c569d authored by Ana's avatar Ana

cambios

parent e278cb59
......@@ -37,21 +37,25 @@ class EnvioSmsController extends FOSRestController {
$mensaje = $_POST['mensaje'];
$idmetodo = $_POST['idmetodo'];
$log = Utiles::setLog('BackendBundle', 'backend/backend');
$log->debug(count(NotificaQuery::create()->filterByCampana($campana)->filterByTelefono($telefono)->find()));
$notifica = NotificaQuery::create()->filterByCampana($campana)->filterByTelefono($telefono)->find();
//$log->debug('mensaje: ' . $mensaje);
$usuario = "";
$password = "";
$url = "";
if ($idmetodo == 1) { //nrsgateway
// $log->debug('mensajeee: ' . $mensaje);
$usuario = Utiles::getParametroConfiguracion('nrsgateway_user');
$password = Utiles::getParametroConfiguracion('nrsgateway_pws');
$url = Utiles::getParametroConfiguracion('nrsgateway_url');
return $this->enviarMensaje($campana, $telefono, $mensaje, $usuario, $password, $url);
} else { //teltech
if ($idmetodo == 2) {
$usuario = Utiles::getParametroConfiguracion('teltech_user');
......@@ -66,13 +70,17 @@ class EnvioSmsController extends FOSRestController {
private function enviarMensaje($campana, $movil, $mensaje, $usuario, $password, $url) {
try {
$log = Utiles::setLog('BackendBundle', 'backend/backend');
$post['to'] = array($movil);
$post['text'] = $mensaje;
$post['from'] = $movil;
$post['dlr-url'] = Utiles::getParametroConfiguracion("url_base") . "/api/notifica/" . $campana . "/%P/%d";
$user = $usuario;
$password = $password;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
......@@ -82,6 +90,9 @@ class EnvioSmsController extends FOSRestController {
"Content-Type: application/json",
"Authorization: Basic " . base64_encode($user . ":" . $password)
));
$result = curl_exec($ch);
$array = json_decode($result, true);
......@@ -95,7 +106,7 @@ class EnvioSmsController extends FOSRestController {
return $resp;
} else {
$log = Utiles::setLog('BackendBundle', 'backend/backend');
$log->debug('entra: ' . count($notifica));
$notifica = NotificaQuery::create()->filterByCampana($campana)->filterByTelefono($movil)->find();
$resp = "";
......@@ -105,7 +116,7 @@ class EnvioSmsController extends FOSRestController {
$estado = $noti->getEstado();
}
$resp = array(
'success' => false,
'success' => true,
'statusCode' => $estado
);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment