Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
smsManager
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Cristian Mauricio Diaz Canales
smsManager
Commits
caed9ab2
Commit
caed9ab2
authored
Jun 13, 2019
by
Ana
Browse files
Options
Browse Files
Download
Plain Diff
resolviendo conflictos
parents
5fdf8e8b
f4565104
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
196 additions
and
0 deletions
+196
-0
src/AppBundle/Model/Sms.php
src/AppBundle/Model/Sms.php
+196
-0
No files found.
src/AppBundle/Model/Sms.php
0 → 100644
View file @
caed9ab2
<?php
namespace
AppBundle\Model
;
use
AppBundle\Model\om\BaseSms
;
use
Monolog\Logger
;
use
Symfony\Component\DependencyInjection\Container
;
use
AppBundle\Lib\Utiles
;
class
Sms
extends
BaseSms
{
const
ELIMINADO_TRUE
=
TRUE
;
const
ELIMINADO_FALSE
=
FALSE
;
const
ESTADO_PREENVIO
=
0
;
const
ESTADO_ENVIADO
=
1
;
const
ESTADO_ENVIADO_NOTIF_OK
=
2
;
const
ESTADO_ENVIADO_NO_OK
=
3
;
const
ESTADO_ENVIADO_NOTIF_NO_OK_BOUNCE
=
4
;
const
ESTADO_ENVIADO_NOTIF_NO_OK_COMPLAINT
=
5
;
const
TIPO_MASIVO
=
1
;
const
TIPO_UNITARIO
=
2
;
public
static
function
enviarSms
(
$url
,
$movil
,
UsuarioMcafee
$usuarioMcafee
,
Batchsms
$batchsms
=
null
,
$campana
=
0
,
$mensaje
,
$tipoSms
,
$transIdCliente
=
null
,
Logger
$log
,
Container
$container
)
{
//$FROM_EMAIL = 'no-reply@seguridadtotalmcafee.cl';
//$FROM_EMAIL = 'fcastro@gearlabs.cl';
$envioEmail
=
null
;
$tag
=
'[enviarSms]'
;
$log
->
debug
(
$tag
.
"entrando... tipoSms:
$tipoSms
| campana:
$campana
| movil:
$movil
| umcId:"
.
$usuarioMcafee
->
getUmcId
());
try
{
$log
->
debug
(
$tag
.
'generando sms...'
);
$sms
=
new
Sms
();
if
(
$sms
!=
null
)
$sms
->
setBatchsmsId
(
$batchsms
->
getBatchsmsId
());
$sms
->
setSmsTipo
(
$tipoSms
);
$sms
->
setUsuarioMcafee
(
$usuarioMcafee
);
$sms
->
setSmsEstado
(
EnvioEmail
::
ESTADO_PREENVIO
);
if
(
$campana
!=
null
)
$sms
->
setSmsCampana
(
$campana
);
$sms
->
setSmsMovil
(
$movil
);
$sms
->
setSmsFechaEnvio
(
new
\DateTime
());
if
(
$transIdCliente
!=
null
)
$sms
->
setSmsTransIdCliente
(
$transIdCliente
);
$sms
->
setSmsEliminado
(
EnvioEmail
::
ELIMINADO_FALSE
);
$sms
->
save
();
//$urlDescarga = Sms::acortarUrl($url);
$urlDescarga
=
$url
;
$mensaje
=
$mensaje
.
$urlDescarga
;
$post
[
'to'
]
=
array
(
$movil
);
$mensaje
=
$mensaje
.
$urlDescarga
;
/* $post['to'] = array($movil);
$post['text'] = $mensaje;
$post['from'] = 'McAfee';
$user ='GearLabs';
$password = 'XCrk02@#';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://sms.teltech.ai/Api/rest/message");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($post));
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,false);
curl_setopt($ch, CURLOPT_HTTPHEADER,
array(
"Accept: application/json",
"Authorization: Basic ".base64_encode($user.":".$password)));
curl_setopt($ch, CURLOPT_TIMEOUT, 50);
$result = json_decode(curl_exec($ch), true);
print_r($result);
//print_r($result['error']['code']);
$log->debug($tag.'enviando mensaje...'. $urlDescarga);*/
/***************************************/
$request
=
'{
"api_key":"9df2cfda7cc871680ede6ec24b4a479d",
"report_url":"http://servidoctor.com/callback/script",
"concat":1,
"messages":[
{
"from":"McAfee",
"to":"584165388803",
"text": "Descarga y participa por un SMART TV DE 50 pulgadas: https://cutt.ly/0i41nK",
"send_at":"2018-02-18 17:30:00"
}
]
}'
;
$headers
=
array
(
'Content-Type: application/json'
);
$ch
=
curl_init
(
'https://api.gateway360.com/api/3.0/sms/send'
);
curl_setopt
(
$ch
,
CURLOPT_POST
,
1
);
curl_setopt
(
$ch
,
CURLOPT_RETURNTRANSFER
,
true
);
curl_setopt
(
$ch
,
CURLOPT_HTTPHEADER
,
$headers
);
curl_setopt
(
$ch
,
CURLOPT_POSTFIELDS
,
$request
);
curl_setopt
(
$ch
,
CURLOPT_SSL_VERIFYPEER
,
false
);
$result
=
curl_exec
(
$ch
);
print_r
(
'RESULTADO2 '
.
$result
);
if
(
curl_errno
(
$ch
)
!=
0
){
die
(
"curl error: "
.
curl_errno
(
$ch
));
}
/***************************************/
if
(
$result
[
'error'
][
'code'
]
==
0
){
$log
->
debug
(
$tag
.
'SMS enviado OK a '
.
$movil
);
$sms
->
setSmsFromMensaje
(
$mensaje
);
$sms
->
setSmsEstado
(
Sms
::
ESTADO_ENVIADO
);
$sms
->
save
();
}
else
{
$sms
->
setSmsEstado
(
Sms
::
ESTADO_ENVIADO_NO_OK
);
$sms
->
setSmsFromMensaje
(
$mensaje
);
$sms
->
save
();
$logError
=
Utiles
::
setLog
(
'AppBundle/Model/sms'
,
'error/sms'
);
$logError
->
err
(
$tag
.
'error enviar sms... movil'
.
$movil
.
' | '
.
print_r
(
array
(
)));
$log
->
err
(
$tag
.
'Se produjo un error al intentar enviar el SMS'
);
return
null
;
}
}
catch
(
\Exception
$e
){
$log
->
err
(
$tag
.
"Execption:
$e
| campana:
$campana
sms:
$movil
| umcId:"
.
$usuarioMcafee
->
getUmcId
());
$logError
=
Utiles
::
setLog
(
'AppBundle/Model/sms'
,
'error/sms'
);
$logError
->
err
(
$tag
.
"usuarioMcafee no encontrado... campana:
$campana
| sms:
$movil
| umcId:"
.
$usuarioMcafee
->
getUmcId
());
return
null
;
}
return
$sms
;
}
/* public static function acortar_url($url) {
$usuario = "gearlabs";
$apikey = "R_8bf0031b8f644fec93997b7b23568b76";
$temp = "http://api.bit.ly/v3/shorten?login=".$usuario."&apiKey=".$apikey."&uri=".$url."&format=txt";
return file_get_contents($temp);
}*/
public
static
function
acortarUrl
(
$data
){
$url
=
"http://url.gearlabs.cl/acortar"
;
$httpStatus
=
null
;
try
{
$ch
=
curl_init
(
$url
);
curl_setopt
(
$ch
,
CURLOPT_POST
,
1
);
curl_setopt
(
$ch
,
CURLOPT_POSTFIELDS
,
$data
);
curl_setopt
(
$ch
,
CURLOPT_RETURNTRANSFER
,
1
);
curl_setopt
(
$ch
,
CURLOPT_TIMEOUT
,
60
);
$output
=
curl_exec
(
$ch
);
$httpStatus
=
curl_getinfo
(
$ch
,
CURLINFO_HTTP_CODE
);
curl_close
(
$ch
);
if
(
$httpStatus
==
200
)
{
$arrayRetorno
=
json_decode
(
$output
,
true
);
return
$arrayRetorno
[
'shortLink'
];
}
else
{
return
array
(
'error'
=>
$httpStatus
);
}
}
catch
(
\Exception
$e
)
{
return
array
(
'error'
=>
'Error'
,
'detalle'
=>
$e
,
);
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment