getMessage(); $reg_status_exec = 'Er'; __logStr("Chamadas Discador Finaz", $reg_msg, $scrpt, true); } @AtualizaIntegracao($uid, $reg_retorno, $reg_msg, $reg_status_exec, $retorno_cliente); if (!$dadosIntegra) @grava_dadosIntegra($reg_retorno); function ChamadaDiscador($contIdentificador, $telefone, $ramalAgente, $uniqueid) { try { $url = "https://api.finaz.com.br/telephony-proxy/atendimentodiscador?" . "pid={$contIdentificador['cont_identificador']}&num={$telefone}&cid={$uniqueid}&ramal={$ramalAgente}&empresaId=3013"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 10); $content = trim(curl_exec($ch)); curl_close($ch); $retorno = json_decode($content); if (!$retorno) { throw new Exception("Erro ao consultar a api - " . $retorno); } $info = array( "url" => $url, "result" => $retorno ); return $info; } catch (Exception $ex) { $msg = $ex->getMessage(); return $msg; } } function ConsultaListaDiscador($connect, $telCliente, $matricula) { try { $query = "SELECT b.cmp_id, a.cmp_descricao, a.list_nome, a.cont_identificador, a.cont_param1, c.nome FROM pbx_campanha_operacao a INNER JOIN pbx_campanha b ON a.cmp_id = b.cmp_id INNER JOIN pbx_dacs c ON c.id = b.id_dac WHERE c.nome = 'REALCONSIG' AND a.conf_fone = '{$telCliente}' AND cmpo_id = (SELECT MAX(cmpo_id) from pbx_campanha_operacao WHERE matricula = '{$matricula}')"; $resultado = pg_query($connect, $query); $resLista = pg_fetch_assoc($resultado); if (!$resultado) { throw new Exception("Erro ao realizar a criação da tabela de listas!"); } return $resLista; } catch (Exception $ex) { return $ex->getMessage(); } } function ConnectPG($connection = null) { $dbPort = "5432"; $dbHost = "127.0.0.1"; $dbName = "pbx"; $dbUser = "contacte"; $dbPassword = "ctepgSQL"; if (!$connection) { $str = "host='$dbHost' port='$dbPort' dbname='$dbName' user='$dbUser' password='$dbPassword'"; return pg_connect($str); } else { pg_close($connection); } return null; } ?>