<?php
header('Content-Type: application/json; charset=utf-8');

$placa = "PQA4703";
$vehicleId = 2555644;
$fingerprint = "t9vF262pEP0uG0oFnk5q";
$terminal = "4068707027";
$proxy = "gate.nodemaven.com:8080";
$proxyAuth = "pkscabelim_gmail_com-country-br-ipv4-true:xcy2s9jsob";

// Este é o token de vídeo/sessão que o Zignet usa para autorizar os débitos
$token = "dKzDV+fkiHZaeiwGKi1Gz6CSpmZqq2KWDQ97Ec8RQuXLZFXTAeEWvgzpJ55Xr59+Bj5t/kdHeWICpg==";

$urlDebts = "https://nfbti53lkd.execute-api.us-east-2.amazonaws.com/dev/site/debts/{$vehicleId}?document=&renavam=482447&chassi=&uf=GO&fingerprintId={$fingerprint}";

$headers = [
    "terminal: {$terminal}",
    "x-fingerprint-site-id: {$fingerprint}",
    "Authorization: Bearer {$token}", // TENTA ENVIAR O TOKEN
    "user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
    "origin: https://www.zignet.com.br",
    "referer: https://www.zignet.com.br/selecao-debitos",
    "accept: application/json, text/plain, */*"
];

$ch = curl_init($urlDebts);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_PROXY, $proxy);
curl_setopt($ch, CURLOPT_PROXYUSERPWD, $proxyAuth);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$res = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

echo json_encode([
    "status_code" => $httpCode,
    "response" => json_decode($res, true) ?: $res
], JSON_PRETTY_PRINT);
