Advertisement
Guest User

Untitled

a guest
May 31st, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. <?php
  2. function conectar_correios5_curl($url){
  3. $ch = curl_init();
  4. curl_setopt($ch, CURLOPT_URL, $url);
  5. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  6. curl_setopt($ch, CURLOPT_FAILONERROR, false);
  7. $result = curl_exec($ch);
  8. curl_close($ch);
  9. $xml = @simplexml_load_string($result);
  10. if(!is_object($xml)) {
  11. return false;
  12. }
  13. return $xml;
  14. }
  15.  
  16. //testa a conexao aos correios
  17. $url = 'http://ws.correios.com.br/calculador/CalcPrecoPrazo.aspx?nCdEmpresa=&sDsSenha=&sCepOrigem=22450000&sCepDestino=22450000&nVlPeso=1,00&nCdFormato=1&nVlComprimento=20,00&nVlLargura=20,00&nVlAltura=20,00&sCdMaoPropria=n&nVlValorDeclarado=27,00&sCdAvisoRecebimento=n&nCdServico=41106,40010,40045&nVlDiametro=0&StrRetorno=xml';
  18.  
  19. print_r(conectar_correios5_curl($url));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement