diff --git a/test_api.php b/test_api.php index 200a536..baa6cbc 100644 --- a/test_api.php +++ b/test_api.php @@ -2,31 +2,15 @@ // Test script to debug create_ticket_api.php echo "=== Testing create_ticket_api.php ===\n\n"; -// Load the API key from hwmonDaemon .env -$hwmonEnv = '/etc/hwmonDaemon/.env'; -$apiKey = null; - -if (file_exists($hwmonEnv)) { - $lines = file($hwmonEnv, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); - foreach ($lines as $line) { - if (strpos($line, 'TICKET_API_KEY=') === 0) { - $apiKey = trim(substr($line, 15)); - // Remove quotes if present - if ((substr($apiKey, 0, 1) === '"' && substr($apiKey, -1) === '"') || - (substr($apiKey, 0, 1) === "'" && substr($apiKey, -1) === "'")) { - $apiKey = substr($apiKey, 1, -1); - } - break; - } - } -} - -if (!$apiKey) { - echo "ERROR: Could not load API key from $hwmonEnv\n"; +// Get API key from command line argument +if (!isset($argv[1])) { + echo "Usage: php test_api.php \n"; + echo "Example: php test_api.php d8f356a06bd5612eca9c5ff948b592a56020cc61937764461458372c9ef30932\n"; exit(1); } -echo "API Key loaded: " . substr($apiKey, 0, 10) . "...\n\n"; +$apiKey = $argv[1]; +echo "API Key: " . substr($apiKey, 0, 10) . "...\n\n"; // Test data $testTicket = [