Commit df0c569d authored by Ana's avatar Ana

cambios

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