#!/usr/bin/php -q ' . "\n"; $xml .= "\n"; $xml .= "view.execute\n"; $xml .= "\n"; $xml .= '' . "\n"; $xml .= "\n"; $xml .= "\n"; $xml .= "\n"; $xml .= "\n"; $xml .= '' . "\n"; $xml .= "\n"; $xml .= "\n"; $xml .= "\n"; $xml .= "\n"; $xml .= '' . "\n"; $xml .= "\n"; $xml .= "\n"; $xml .= "\n"; $xml .= "\n"; $xml .= '' . "\n"; $xml .= "\n"; $xml .= "\n"; $xml .= "\n"; $xml .= "\n"; $xml .= sprintf('' . "\n",$param['type']); $xml .= "\n"; $xml .= "\n"; $xml .= "\n"; $xml .= "\n"; $xml .= "\n"; $xml .= ""; $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, $xml); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml; charset=utf-8', 'Content-Length: ' . strlen($xml))); $result = curl_exec($ch); $curlError = curl_error($ch); if ($curlError == '') { $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); if ($httpCode == 200) { if ($result == '') { throw new Exception("Void Response"); } else { $xml = simplexml_load_string($result); $retorno = array(); //$retorno['cpf_cnpj'] = $xml->params->param[1]->value->DOMElement->result->row->cpf_cnpj; //$retorno['susp_deb'] = $xml->params->param[1]->value->DOMElement->result->row->susp_deb; $retorno['codcli'] = $xml->params->param[1]->value->DOMElement->result->row->codcli; } } else { throw new Exception("HTTP error ocurred, number: $httpCode"); } } else { curl_close($ch); throw new Exception("HTTP error ocurred: $curlError"); } return $retorno; } function RemoveMask($telefone) { $retorno = array('telefone' => '', 'type' => ''); if (strlen($telefone) == 9) { $telefone = "(21)" . $telefone; $retorno['telefone'] = $telefone; $retorno['type'] = 'celular'; } else if (strlen($telefone) == 11) { $ddd = substr($telefone, 0, 2); $numero = substr($telefone, 2, 10); $telefone = sprintf("(%s)%s", $ddd, $numero); $retorno['telefone'] = $telefone; $retorno['type'] = 'celular'; } else if (strlen($telefone) == 8) { $telefone = "(21)" . $telefone; $retorno['telefone'] = $telefone; $retorno['type'] = 'fone'; } else if (strlen($telefone) == 10) { $ddd = substr($telefone, 0, 2); $numero = substr($telefone, 2, 9); $telefone = sprintf("(%s)%s", $ddd, $numero); $retorno['telefone'] = $telefone; $retorno['type'] = 'fone'; } return $retorno; } ?>