Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //datos de factura RFC emisor, RFC receptor, Total, UUID
- //@toro https://tar.mx/archivo/2018/validar-folio-fiscal-cfdi-con-php-directo-del-sat-2018.html
- $emisor="";
- $receptor="";
- $total="";
- $uuid="";
- //
- $soap = sprintf('<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/"><soapenv:Header/><soapenv:Body><tem:Consulta><tem:expresionImpresa>?re=%s&rr=%s&tt=%s&id=%s</tem:expresionImpresa></tem:Consulta></soapenv:Body></soapenv:Envelope>', $emisor,$receptor,$total,$uuid);
- //encabezados
- $headers = [
- 'Content-Type: text/xml;charset=utf-8',
- 'SOAPAction: http://tempuri.org/IConsultaCFDIService/Consulta',
- 'Content-length: '.strlen($soap)
- ];
- $url = 'https://consultaqr.facturaelectronica.sat.gob.mx/ConsultaCFDIService.svc';
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($ch, CURLOPT_POST, true);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $soap);
- curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
- $res = curl_exec($ch);
- curl_close($ch);
- $xml = simplexml_load_string($res);
- $data = $xml->children('s', true)->children('', true)->children('', true);
- $data = json_encode($data->children('a', true), JSON_UNESCAPED_UNICODE);
- print_r(json_decode($data));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement