<?php
// Script de prueba cURL para Digifact

$url = 'https://testnucgt.digifact.com/api/login/get_token';

// Datos de prueba (reemplaza con tus credenciales de prueba)
$username = 'GT.000000123456.USER_TEST'; 
$password = 'TU_PASSWORD_TEST';

// Convertimos a JSON
$data = json_encode([
    'Username' => $username,
    'Password' => $password
]);

// Inicializamos cURL
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);

// Para pruebas locales ignoramos SSL
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);

// Ejecutamos cURL
$response = curl_exec($ch);
$error = curl_error($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

// Mostramos resultados
echo "<pre>";
echo "HTTP Code: $http_code\n";
echo "Error cURL: $error\n";
echo "Response: $response\n";
echo "</pre>";
