Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.    /* @toro 2018 tar.mx -- consultar estado de factura directo al SAT */
  3.    //datos de factura RFC emisor, RFC receptor, Total, UUID
  4.    $emisor="";
  5.    $receptor="";
  6.    $total="";
  7.    $uuid="";
  8.    //
  9.    $soap = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/"><soapenv:Header/><soapenv:Body><tem:Consulta><tem:expresionImpresa>?re='.$emisor.'&amp;rr='.$receptor.'&amp;tt='.$total.'&amp;id='.$uuid.'</tem:expresionImpresa></tem:Consulta></soapenv:Body></soapenv:Envelope>';
  10.   //encabezados
  11.    $headers = [
  12.    'Content-Type: text/xml;charset=utf-8',
  13.   'SOAPAction: http://tempuri.org/IConsultaCFDIService/Consulta',
  14.   'Content-length: '.strlen($soap)
  15.   ];
  16.  
  17.    $url = 'https://consultaqr.facturaelectronica.sat.gob.mx/ConsultaCFDIService.svc';
  18.   $ch = curl_init();
  19.    curl_setopt($ch, CURLOPT_URL, $url);
  20.    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  21.    curl_setopt($ch, CURLOPT_POST, true);
  22.    curl_setopt($ch, CURLOPT_POSTFIELDS, $soap);
  23.    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
  24.    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
  25.    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  26.    $res = curl_exec($ch);
  27.    curl_close($ch);
  28.    $xml = simplexml_load_string($res);
  29.    $data = $xml->children('s', true)->children('', true)->children('', true);
  30.   $data = json_encode($data->children('a', true), JSON_UNESCAPED_UNICODE);
  31.   print_r(json_decode($data));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement