Update test script to accept API key as parameter
This commit is contained in:
28
test_api.php
28
test_api.php
@@ -2,31 +2,15 @@
|
|||||||
// Test script to debug create_ticket_api.php
|
// Test script to debug create_ticket_api.php
|
||||||
echo "=== Testing create_ticket_api.php ===\n\n";
|
echo "=== Testing create_ticket_api.php ===\n\n";
|
||||||
|
|
||||||
// Load the API key from hwmonDaemon .env
|
// Get API key from command line argument
|
||||||
$hwmonEnv = '/etc/hwmonDaemon/.env';
|
if (!isset($argv[1])) {
|
||||||
$apiKey = null;
|
echo "Usage: php test_api.php <api_key>\n";
|
||||||
|
echo "Example: php test_api.php d8f356a06bd5612eca9c5ff948b592a56020cc61937764461458372c9ef30932\n";
|
||||||
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";
|
|
||||||
exit(1);
|
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
|
// Test data
|
||||||
$testTicket = [
|
$testTicket = [
|
||||||
|
|||||||
Reference in New Issue
Block a user