Commit 1c5414f9 authored by Ana's avatar Ana

cambgios

parents ba88a816 22830ccf
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<type>org.netbeans.modules.php.project</type> <type>org.netbeans.modules.php.project</type>
<configuration> <configuration>
<data xmlns="http://www.netbeans.org/ns/php-project/1"> <data xmlns="http://www.netbeans.org/ns/php-project/1">
<name>intelsecuritymovistar</name> <name>smsmanager</name>
</data> </data>
</configuration> </configuration>
</project> </project>
...@@ -6,23 +6,20 @@ use FOS\RestBundle\Controller\FOSRestController; ...@@ -6,23 +6,20 @@ use FOS\RestBundle\Controller\FOSRestController;
use AppBundle\Lib\Utiles; use AppBundle\Lib\Utiles;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
//use Symfony\Component\Routing\Annotation\Route; //use Symfony\Component\Routing\Annotation\Route;
use AppBundle\Model\NotificaQuery; use AppBundle\Model\NotificaQuery;
use AppBundle\Model\Notifica; use AppBundle\Model\Notifica;
use AppBundle\Model\RespuestasSmsQuery; use AppBundle\Model\RespuestasSmsQuery;
use AppBundle\Model\RespuestasSms; use AppBundle\Model\RespuestasSms;
require_once __DIR__ . '/../../../vendor/autoload.php'; require_once __DIR__ . '/../../../vendor/autoload.php';
use FOS\RestBundle\View\View; use FOS\RestBundle\View\View;
//use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method; //use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
class EnvioSmsController extends FOSRestController { class EnvioSmsController extends FOSRestController {
//* @Route("/enviar") //* @Route("/enviar")
public function indexAction($id) { public function indexAction($id) {
...@@ -31,7 +28,6 @@ class EnvioSmsController extends FOSRestController { ...@@ -31,7 +28,6 @@ class EnvioSmsController extends FOSRestController {
return $this->handleView($view); return $this->handleView($view);
} }
// * @Route("/enviar") // * @Route("/enviar")
// * @Method({"POST"}) // * @Method({"POST"})
...@@ -63,7 +59,6 @@ class EnvioSmsController extends FOSRestController { ...@@ -63,7 +59,6 @@ class EnvioSmsController extends FOSRestController {
return $this->enviarMensaje($campana, $telefono, $mensaje, $usuario, $password, $url, $from, $idmetodo); return $this->enviarMensaje($campana, $telefono, $mensaje, $usuario, $password, $url, $from, $idmetodo);
} else { //teltech } else { //teltech
if ($idmetodo == 2) { if ($idmetodo == 2) {
$log->debug('Selecciona Teltech'); $log->debug('Selecciona Teltech');
...@@ -79,7 +74,7 @@ class EnvioSmsController extends FOSRestController { ...@@ -79,7 +74,7 @@ class EnvioSmsController extends FOSRestController {
} }
private function enviarMensaje($campana, $movil, $mensaje, $usuario, $password, $url, $from, $proveedor) { private function enviarMensaje($campana, $movil, $mensaje, $usuario, $password, $url, $from, $proveedor) {
try {
$log = Utiles::setLog('BackendBundle', 'backend/backend'); $log = Utiles::setLog('BackendBundle', 'backend/backend');
...@@ -102,8 +97,9 @@ class EnvioSmsController extends FOSRestController { ...@@ -102,8 +97,9 @@ class EnvioSmsController extends FOSRestController {
"Authorization: Basic " . base64_encode($user . ":" . $password) "Authorization: Basic " . base64_encode($user . ":" . $password)
)); ));
$result = curl_exec($ch);
$result = curl_exec($ch);
// $log->debug(print_r($result,true));
$array = json_decode($result, true); $array = json_decode($result, true);
$resp = ""; $resp = "";
...@@ -123,6 +119,30 @@ class EnvioSmsController extends FOSRestController { ...@@ -123,6 +119,30 @@ class EnvioSmsController extends FOSRestController {
$resp = ""; $resp = "";
if (count($notifica) > 0) {
foreach ($notifica as $noti) {
$estado = $noti->getEstado();
}
$resp = array(
'success' => true,
'statusCode' => $estado
);
// return $resp;
} else {
$estado = $array['error']['code'];
$resp = array(
'success' => false,
'statusCode' => $array['error']['code']
);
<<<<<<< HEAD
//return $resp;
} else {
$log->debug('Api envio exitoso');
$notifica = NotificaQuery::create()->filterByCampana($campana)->filterByTelefono($movil)->find();
$resp = "";
if (count($notifica) > 0) { if (count($notifica) > 0) {
foreach ($notifica as $noti) { foreach ($notifica as $noti) {
$estado = $noti->getEstado(); $estado = $noti->getEstado();
...@@ -141,6 +161,10 @@ class EnvioSmsController extends FOSRestController { ...@@ -141,6 +161,10 @@ class EnvioSmsController extends FOSRestController {
); );
// return $resp; // return $resp;
} }
=======
// return $resp;
>>>>>>> 22830ccf3f37fe0ceed3609fae2da773696ebb89
}
} }
try { try {
$log->debug('Grabar en respuestaSms'); $log->debug('Grabar en respuestaSms');
...@@ -153,14 +177,11 @@ class EnvioSmsController extends FOSRestController { ...@@ -153,14 +177,11 @@ class EnvioSmsController extends FOSRestController {
$respuestaSms->setResHttpCodeRespuestaPeticion($estado); $respuestaSms->setResHttpCodeRespuestaPeticion($estado);
$respuestaSms->save(); $respuestaSms->save();
} catch (PropelException $pe) { } catch (PropelException $pe) {
$log = Utiles::setLog('exception'); //$log = Utiles::setLog('exception');
$log->debug('Propelexception: ' . $pe->getMessage()); $log->debug('Propelexception: ' . $pe->getMessage());
} }
return $resp; return $resp;
} catch (\Exception $e) {
$log = Utiles::setLog('exception');
$log->debug('exception: ' . $e);
}
} }
private function enviarMensajeAmazon($telefono, $mensaje, $from, $proveedor) { private function enviarMensajeAmazon($telefono, $mensaje, $from, $proveedor) {
...@@ -183,7 +204,6 @@ class EnvioSmsController extends FOSRestController { ...@@ -183,7 +204,6 @@ class EnvioSmsController extends FOSRestController {
return $messageId; return $messageId;
} }
// * @Route("/buscarstatus") // * @Route("/buscarstatus")
// * @Method({"POST"}) // * @Method({"POST"})
public function buscarStatusAction() { public function buscarStatusAction() {
...@@ -220,8 +240,8 @@ class EnvioSmsController extends FOSRestController { ...@@ -220,8 +240,8 @@ class EnvioSmsController extends FOSRestController {
if ($result['events']) { if ($result['events']) {
$status = json_decode($result['events'][0]['message'], true); $status = json_decode($result['events'][0]['message'], true);
$telefono= $status['delivery']['destination']; $telefono = $status['delivery']['destination'];
$estado= $status['status']; $estado = $status['status'];
$notifica = new Notifica(); $notifica = new Notifica();
...@@ -243,8 +263,8 @@ class EnvioSmsController extends FOSRestController { ...@@ -243,8 +263,8 @@ class EnvioSmsController extends FOSRestController {
$telefono = ''; $telefono = '';
if ($result['events']) { if ($result['events']) {
$status = json_decode($result['events'][0]['message'], true); $status = json_decode($result['events'][0]['message'], true);
$telefono= $status['delivery']['destination']; $telefono = $status['delivery']['destination'];
$estado= $status['status']; $estado = $status['status'];
$notifica = new Notifica(); $notifica = new Notifica();
...@@ -264,7 +284,6 @@ class EnvioSmsController extends FOSRestController { ...@@ -264,7 +284,6 @@ class EnvioSmsController extends FOSRestController {
} }
} }
// * @Route("/notifica/{idenvio}/{tel}/{estado}") // * @Route("/notifica/{idenvio}/{tel}/{estado}")
public function notificaAction($idenvio, $tel, $estado) { public function notificaAction($idenvio, $tel, $estado) {
...@@ -275,4 +294,5 @@ class EnvioSmsController extends FOSRestController { ...@@ -275,4 +294,5 @@ class EnvioSmsController extends FOSRestController {
$notifica->save(); $notifica->save();
} }
} }
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