Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $url = "http://ws.correios.com.br/calculador/CalcPrecoPrazo.aspx?";
- $url .= "nCdEmpresa=" . $cod_administrativo;
- $url .= "&sDsSenha=" . $senha;
- $url .= "&sCepOrigem=" . $cep_origem;
- $url .= "&sCepDestino=" . $cep_destino;
- $url .= "&nVlPeso=" . $peso;
- $url .= "&nVlLargura=" . $largura;
- $url .= "&nVlAltura=" . $altura;
- $url .= "&nCdFormato=1";
- $url .= "&nVlComprimento=" . $comprimento;
- $url .= "&sCdMaoPropria=" . $mao_propria;
- $url .= "&nVlValorDeclarado=" . $valor;
- $url .= "&sCdAvisoRecebimento=" . $aviso_recebimento;
- $url .= "&nCdServico=" . $servico;
- $url .= "&nVlDiametro=0";
- $url .= "&StrRetorno=xml";
- $xml = simplexml_load_file($url);
- if ($xml === false || $xml === 0 || $xml === "") {
- return '';
- }
- return $xml->cServico;
- // nescessΓ‘rio pra consegui pegar os errors
- libxml_use_internal_errors(true);
- $xml = simplexml_load_file($filePath);
- if ($xml === false) {
- $message = '';
- foreach (libxml_get_errors() as $error) {
- $message .= $error->message;
- }
- throw new Exception(trim($message));
- }
- if (simplexml_load_file($url)) {
- $xml = simplexml_load_file($url)
- return $xml->cServico;
- } else {
- echo 'SUA MENSAGEM';
- }
Add Comment
Please, Sign In to add comment