|
|
<?php |
|
|
|
|
|
$servidorApi = GetServerApi(); |
|
|
//$servidorApi = "localhost:90/simplesip"; |
|
|
$userApi = "sinccontasenha"; |
|
|
$senhaApi = "s3ncC0nt@S2nh@"; |
|
|
|
|
|
|
|
|
function ExecDb($pCmd) { |
|
|
global $servidorApi, $userApi, $senhaApi; |
|
|
|
|
|
$cmd = array(); |
|
|
$cmd[] = $pCmd; |
|
|
$pCmd = EncodeParam($cmd); |
|
|
$url = "http://$servidorApi/integracao?method=ExecDb&pCmd=$pCmd&login=$userApi&senha=$senhaApi&tipoRetorno=XML"; |
|
|
|
|
|
$xml = simplexml_load_string(GetApi($url)); |
|
|
$ret = array(); |
|
|
$ret["status"] = strval($xml->status); |
|
|
$ret["result"] = strval($xml->result); |
|
|
$ret["message"] = strval($xml->message); |
|
|
|
|
|
return $ret; |
|
|
} |
|
|
|
|
|
function GetSequenciaMaster($pCmd) { |
|
|
global $servidorApi, $userApi, $senhaApi; |
|
|
|
|
|
//$url = "http://$servidorApi/integracao?method=$metodo$params&encode=$encode&login=$userApi&senha=$senhaApi&tipoRetorno=XML"; |
|
|
$url = "http://$servidorApi/integracao?method=GetSequenciaMaster&nomeTable=$pCmd&login=$userApi&senha=$senhaApi&tipoRetorno=XML"; |
|
|
//$url = "http://192.168.115.17/integracao?method=GetSequenciaMaster&nomeTable=$pCmd&login=$userApi&senha=$senhaApi&tipoRetorno=XML"; |
|
|
$xml = simplexml_load_string(GetApi($url)); |
|
|
$ret = array(); |
|
|
$ret["status"] = strval($xml->status); |
|
|
$ret["result"] = strval($xml->result); |
|
|
return $ret; |
|
|
} |
|
|
|
|
|
function AutenticaApi() { |
|
|
global $servidorApi, $userApi, $senhaApi; |
|
|
$url = "http://$servidorApi/integracao?method=AutenticaUsuario&login=$userApi&senha=$senhaApi&tipoRetorno=XML"; |
|
|
$xml = simplexml_load_string(GetApi($url)); |
|
|
return ($xml->result[0] == "true") ? srtval($xml->SIPID) : false; |
|
|
} |
|
|
|
|
|
function GetApi($url, $params = array()) { |
|
|
if (!count($params)) { |
|
|
return @file_get_contents($url); |
|
|
} |
|
|
/* |
|
|
* Para arquivos passe o parametro no formato indicado: |
|
|
* "'file_contents'=>'@'.$file_name_with_full_path"; |
|
|
* Exemplo array params: |
|
|
* array('extra_info' => '123456','file_contents'=>'@'.$file_name_with_full_path); |
|
|
*/ |
|
|
$server_output = ''; |
|
|
$ch = curl_init(); |
|
|
if (IsPhp6()) { |
|
|
curl_setopt($ch, CURLOPT_SAFE_UPLOAD, true); |
|
|
} |
|
|
curl_setopt($ch, CURLOPT_URL, $url); |
|
|
|
|
|
$headers = array("Content-Type: text/xml; charset=iso-8859-1", "Accept: text/xml"); |
|
|
/* |
|
|
* M<EFBFBD>todo post. |
|
|
*/ |
|
|
if (count($params)) { |
|
|
curl_setopt($ch, CURLOPT_POST, 1); |
|
|
curl_setopt($ch, CURLOPT_TIMEOUT, 120); |
|
|
curl_setopt($ch, CURLOPT_BUFFERSIZE, 128); |
|
|
curl_setopt($ch, CURLOPT_POSTFIELDS, $params); |
|
|
} |
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
|
|
$server_output = curl_exec($ch); |
|
|
curl_close($ch); |
|
|
|
|
|
return $server_output; |
|
|
} |
|
|
|
|
|
?>
|
|
|
|