Commit 1c5414f9 authored by Ana's avatar Ana

cambgios

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