Browse Source

ajustes diversos

master
douglasstrappasson 1 year ago
parent
commit
56329eebbe
  1. 2
      IXC/IxcSoft.php
  2. 7
      IXC/consultaCliente.php
  3. 23
      Mobile21/Mobile21.php
  4. 47
      Mobile21/send.php
  5. 69
      Mobile21/teste.php
  6. 1
      Piperun/sms_mobile.log
  7. 60
      Piperun/webhookMobile.php
  8. 17
      shared/config.php

2
IXC/IxcSoft.php

@ -278,7 +278,7 @@
$this->setMetodo('get_boleto');
foreach ($faturas as $invoice) {
if (strtotime($invoice['data_vencimento'] . ' 23:59:59') < strtotime("+".CONF_FATURA_DIAS_APOS." month", time()) && $invoice['valor_aberto'] > 0) {
if (strtotime($invoice['data_vencimento'] . ' 23:59:59') < strtotime("+".CONF_FATURA_DIAS_APOS." days", time()) && $invoice['valor_aberto'] > 0) {
$this->params = array(
"boletos" => $invoice['id'],
"juro" => "N",

7
IXC/consultaCliente.php

@ -7,13 +7,10 @@
$retorno = $ixc->buscarCliente($documento);
$reg_pass = $ixc->agi()->get_variable("REG_PASS", true);
$nomenclatura = str_replace("IDENTIFICACAO", "", $ixc->db()->getUraMovimentoByUniqueid($uid)['umv_ura_nome']);
$nameURA = $ixc->db()->getUraMovimentoByUniqueid($uid)['umv_ura_nome'];
$nomenclatura = substr($nameURA, strpos($nameURA, "_INT_"));
$ixc->agi()->set_variable("NOMENCLATURA", $nomenclatura);
//Dados:
if ($retorno['total'] >= 1) {
//verifica apenas cadastro ativo

23
Mobile21/Mobile21.php

@ -0,0 +1,23 @@
<?php
require_once "Integracao.php";
include 'config.php';
/**
* Classe para utilizar as API da empresa 21Mobile
*
* @documentation: https://api.21mobile.com.br/docs/v1/http
* @author Douglas Fernando Strappasson
* @function junior developer
* @company SimplesIP
* @version 1.0.1
*/
class Mobile21 extends Integracao {
$token = base64_encode("USERNAME" . ":" . "PASSWORD");
$messageText = "TESTE API v1 21MOBILE";
$destination = "11999999999";
$correlationId = "idDeControle";
};

47
Mobile21/send.php

@ -0,0 +1,47 @@
<?php
$curl = curl_init();
$token = base64_encode("USERNAME" . ":" . "PASSWORD");
$messageText = "TESTE API v1 21MOBILE";
$destination = "11999999999";
$correlationId = "idDeControle";
$json = json_encode(
array(
"sms" => array(
array(
"messageText" => $messageText,
"destination" => $destination,
"correlationId" => $correlationId
)
)
)
);
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.21mobile.com.br/v1/send",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => $json,
CURLOPT_HTTPHEADER => array(
"authorization: token$token $token",
"cache-control: no-cache",
"content-type: application/json",
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}

69
Mobile21/teste.php

@ -0,0 +1,69 @@
<?php
function enviaSMSMobile($numeroDestino, $texto, $clientId = ""){
$user = 'simples_ip';
$senha = '2imms0f';
$token = base64_encode($user.":".$senha);
$minDate = 1672545600;
$metodo = 'send';
$request = 'POST';
$params = array(
"sms" => array(
array(
"messageText" => $texto,
"destination" => $numeroDestino
)
)
);
return setParams($request, $params, $metodo, $token);
}
function setParams($request, $params, $metodo, $token){
if (strtoupper($request) == "POST"){
$query = json_encode($params);
}
if (strtoupper($request) == "GET"){
if($params){
$count = 0;
$query = "?";
foreach ($params as $key => $value){
$query .= "{$key}={$value}";
if ($params != ++$count){
$query .= "&";
}
}
}
}
unset($params);
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.21mobile.com.br/v1/{$metodo}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_POSTFIELDS => strtoupper($request) == "POST" ? "POST" : "",
CURLOPT_CUSTOMREQUEST => strtoupper($request),
CURLOPT_HTTPHEADER => array(
"authorization: Basic $token",
"cache-control: no-cache",
"content-type: application/json",
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
throw new Exception("ERRO! - . $err");
} else {
return $response;
}
}

1
Piperun/sms_mobile.log

@ -0,0 +1 @@
Requisicao invalida para o WebHook! A requisicao foi delegada.

60
Piperun/webhookMobile.php

@ -0,0 +1,60 @@
<?php
#######################################
### WEBHOOK PARA 21Moblie SMS ###
#######################################
/**
* Este script tem a finalidade de receber as requisicoes via GET do webhook
* e atualizar o status do sms no banco de dados.
*/
include ("bd.php");
define('CONF_LOGGER_REQUEST', '/var/log/asterisk/sms_mobile.log');
setLog("Edereco IP: ".$_SERVER["REMOTE_ADDR"]);
// Desativa a exibição de erros na tela do navegador em seguida direciona os erros para o arquivo de log
ini_set('display_errors', 'Off');
ini_set('error_log', CONF_LOGGER_REQUEST);
header("Access-Control-Allow-Origin: *");
header("Content-Type: application/json; charset=UTF-8");
header("Access-Control-Allow-Methods: GET");
header("Access-Control-Max-Age: 3600");
header("Access-Control-Allow-Headers: Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With, x-amzn-trace-id");
try {
$data = filter_input_array(INPUT_GET, FILTER_SANITIZE_SPECIAL_CHARS);
$errorParam = "ERRO: Requisicao invalida para o WebHook! Os parametros nao foram informados.";
extract($data);
if (!isset($correlationId) || !isset($status)){
throw new Exception($errorParam);
}
updateData($dbcon, $correlationId, $status);
return http_response_code(200);
} catch (Exception $ex) {
setLog($ex->getMessage());
return http_response_code(400);
}
function setLog($msgError) {
file_put_contents(CONF_LOGGER_REQUEST, $msgError . date(' d-m-Y - H:i:s') . PHP_EOL, FILE_APPEND);
}
/**
* esta funcao realiza o update no banco de dados.
*/
function updateData($dbcon, $correlationId, $status) {
$errorDb = "ERRO: Nao foi possivel realizar a insercao no banco de dados!";
$query = sprintf("UPDATE pbx_sms_send SET sms_status = '%s' WHERE sms_id_envio = '%s'", $status, $correlationId);
pg_query($dbcon, $query);
if (pg_last_error()) {
throw new Exception($errorDb . pg_last_error());
}
}

17
shared/config.php

@ -8,19 +8,16 @@
###########################################################################
define('CONF_ID_CREDENCIAIS', '');
define('CONF_TOKEN_API', '52:813646b57b26d75ce1ad1dab527db5a8e30553a2f96e3d01d6f0f2ac2d642665');
define('CONF_URL_API', 'https://ixc.conectainter.net.br');
define('CONF_USER_API', 'simplesipintegracao@conectabrasil.net');
define('CONF_PASSWORD_API', '@#Conecta2023');
define('CONF_USERID_API', '52');
define('CONF_TOKEN_API', '194:5116b78c5779d152a557f1e2baa2491a6aca779125389f354867f8b54a2a4892');
define('CONF_URL_API', 'https://gerencia.rapidfibra.com.br');
define('CONF_USER_API', 'simplesip@rapidfibra.com.br');
define('CONF_PASSWORD_API', '3NwDZb7h@');
define('CONF_USERID_API', '194');
###########################################################################
##### CONFIGURACOES #####
###########################################################################
define("CONF_INTEGRACAO_TELA", true);
define("CONF_PARAMETROS_TELA", serialize(array("NOME", "PLANO", "ENDERECO", "IP", "STATUS", "OBSERVACOES")));
/** @CONF_NOME_EMPRESA => colocar _EMPRESA */
define('CONF_NOME_EMPRESA', '');
@ -34,8 +31,6 @@
define('CONF_FATURA_DIAS_ANTES', 30);
define('CONF_FATURA_DIAS_APOS', 5);
define('CONF_AUDIO_ERROR', 'INTEGRACAO_ERRO_INT');
###########################################################################
##### CREDENCIAIS DE ENVIO DE EMAIL #####
###########################################################################
@ -73,7 +68,7 @@
############################################################################
define("CONF_INTEGRACAO_TELA", true);
define("CONF_PARAMETROS_TELA", serialize(array("DOCUMENTO", "NOME", "PLANO", "ENDERECO", "STATUS", "EMAIL")));
define("CONF_PARAMETROS_TELA", serialize(array("NOME", "PLANO", "ENDERECO", "IP", "STATUS", "OBSERVACOES")));
###########################################################################
##### CONFIGURACAO DE PARADA TECNICA HUBSOFT #####

Loading…
Cancel
Save