<?php

$url = 'https://officepower.click/api/auth/login';

$data = [
    "captcha" => "not-a-robot",
    "captchaChecked" => true,
    "username" => "dbldigltal",
    "password" => "20078714332@Db",
    "twofactor_code" => "",
    "twofactor_recovery_code" => "",
    "twofactor_trusted_device_id" => "4h4f07BaQG1Y9upGD8bAlLwIyVFq9TJvbgdkqquL6tb5wfxroFoibW1SzNxeE5og"
];

// COLE AQUI OS COOKIES CAPTURADOS NO CHARLES OU NAVEGADOR
$cookies = 'cf_clearance=PASTE_HERE; session=PASTE_HERE';

$headers = [
    'Content-Type: application/json',
    'Accept: application/json, text/plain, */*',
    'X-Requested-With: XMLHttpRequest',
    'Origin: https://officepower.click',
    'Referer: https://officepower.click/login',
    'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36',
    "Cookie: $cookies"
];

$postFields = json_encode($data);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields);
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$response = curl_exec($ch);
$error = curl_error($ch);
curl_close($ch);

echo "<pre>";
if ($error) {
    echo "Erro cURL: $error";
} else {
    echo "Resposta da API:\n\n";
    var_dump($response);

    $responseData = json_decode($response, true);
    if (isset($responseData['token'])) {
        echo "\n\n<strong>Token JWT:</strong> " . $responseData['token'];
    }
}
echo "</pre>";
