#!/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 .= '' . "\n"; $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 == '') { echo ("Void Response"); } else { $xml = simplexml_load_string($result, null, LIBXML_NOBLANKS | LIBXML_NOCDATA); $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; $res = json_decode(json_encode($retorno), 1); } } else { echo ("HTTP error ocurred, number: $httpCode"); } } else { curl_close($ch); echo ("HTTP error ocurred: $curlError"); } return $res; } /*function xmlToArray($xmlObj, $output = array()) { foreach ((array) $xmlObj as $index => $node) { $output[$index] = (is_object($node)) ? xmlToArray($node) : $node; } return $output; }*/