<?php
// consultar_status_direto.php

$ref = "nota_1781101834518"; // Sua referência
$token = "T6BuPKa33JP2oXtJUsTanOnl5lf3DeFl";
$ambiente = "homologacao";

$baseUrl = $ambiente == 'producao' ? 'https://api.focusnfe.com.br/v2' : 'https://homologacao.focusnfe.com.br/v2';

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $baseUrl . '/nfsen/' . urlencode($ref));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Authorization: Basic ' . base64_encode($token . ':')
]);
$resposta = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

echo "HTTP Code: $httpCode\n";
echo "Resposta:\n";
echo json_encode(json_decode($resposta), JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE);
echo "\n";
?>