forked from SimplesIP/pabx-app
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
75 lines
2.0 KiB
75 lines
2.0 KiB
2 years ago
|
<?php
|
||
|
|
||
|
error_reporting(E_ALL);
|
||
|
ini_set('display_errors', true);
|
||
|
|
||
|
|
||
|
|
||
|
$cliente = abreProtocoloRBX('2', '1');
|
||
|
|
||
|
print_r($cliente);
|
||
|
|
||
|
|
||
|
|
||
|
function abreProtocoloRBX($idCliente, $atendimento) {
|
||
|
|
||
|
$url = "https://central.openitgroup.com.br/routerbox/ws/rbx_server_json.php";
|
||
|
$dateTime = date('Y-m-d H:i:s');
|
||
|
$dataHora = explode(" ", $dateTime);
|
||
|
|
||
|
if ($atendimento == 3) {
|
||
|
//PROTOCOLO COMERCIAL
|
||
|
$assunto = 'Comercial';
|
||
|
} else if ($atendimento == 2) {
|
||
|
//PROTOCOLO FINANCEIRO
|
||
|
$assunto = 'Financeiro';
|
||
|
} else if ($atendimento == 1) {
|
||
|
//PROTOCOLO SUPORTE
|
||
|
$assunto = 'Suporte';
|
||
|
}
|
||
|
|
||
|
$json = "{
|
||
|
\AtendimentoCadastro\": {
|
||
|
\"Autenticacao\": {
|
||
|
\"ChaveIntegracao\": \"MIZ78UZP7OZ4API5DK14Q0QYWBKFFN\"
|
||
|
},
|
||
|
\"DadosAtendimento\": {
|
||
|
\"Data_Abertura\": \"$dataHora[0]\",
|
||
|
\"Hora_Abertura\": \"$dataHora[1]\",
|
||
|
\"Iniciativa\": \"C\",
|
||
|
\"Modo\": \"A\",
|
||
|
\"TipoCliente\": \"C\",
|
||
|
\"Cliente\": \"$idCliente\",
|
||
|
\"Assunto\": \"$assunto\"
|
||
|
}
|
||
|
}
|
||
|
}";
|
||
|
|
||
|
$ch = curl_init();
|
||
|
curl_setopt($ch, CURLOPT_URL, $url);
|
||
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||
|
curl_setopt($ch, CURLOPT_POST, 1);
|
||
|
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
||
|
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
|
||
|
curl_setopt($ch, CURLOPT_POSTFIELDS, $json);
|
||
|
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
|
||
|
'Content-Type: text/xml; charset=utf-8',
|
||
|
'Content-Length: ' . strlen($json)
|
||
|
));
|
||
|
$result = curl_exec($ch);
|
||
|
$retCliente = json_decode($result);
|
||
|
|
||
|
return objectToArray($retCliente);
|
||
|
}
|
||
|
|
||
|
function objectToArray($d) {
|
||
|
if (is_object($d)) {
|
||
|
$d = get_object_vars($d);
|
||
|
}
|
||
|
if (is_array($d)) {
|
||
|
return array_map(__FUNCTION__, $d);
|
||
|
} else {
|
||
|
return $d;
|
||
|
}
|
||
|
}
|