Skip to content

Instantly share code, notes, and snippets.

@acras
Created September 6, 2016 02:51
Show Gist options
  • Save acras/d37ac890ed0075d8c95e7d9a8bf48c16 to your computer and use it in GitHub Desktop.
Save acras/d37ac890ed0075d8c95e7d9a8bf48c16 to your computer and use it in GitHub Desktop.
Exemplo de consulta de NFSe emitida pela API Focus NFe em PHP usando CURL
<?php
$ch = curl_init();
$token = "aaOqeu3poIWHM1VksU7EzVKPsai9RxGyM" //Substituir pelo token enviado pelo suporte
$ref = 12345 //Substituir pela sua identificação interna da nota
curl_setopt($ch, CURLOPT_URL, "http://homologacao.acrasnfe.acras.com.br/nfse/" . $ref . "?token=" . $token);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array());
$body = curl_exec($ch);
$result = curl_getinfo($ch, CURLINFO_HTTP_CODE);
//as três linhas abaixo imprimem as informações retornadas pela API, aqui o seu sistema deverá
//interpretar e lidar com o retorno
print("STATUS: ".$result."\n");
print("BODY: ".$body."\n\n");
print("");
curl_close($ch);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment