From 74da7bf819460041998207c5900fe99db424577e Mon Sep 17 00:00:00 2001 From: Jared Vititoe Date: Thu, 1 Jan 2026 17:00:12 -0500 Subject: [PATCH] Update test script to accept API key as parameter --- test_api.php | 28 ++++++---------------------- 1 file changed, 6 insertions(+), 22 deletions(-) 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 = [