app_modules->is_active('api')) { echo "✅ API module is active\n"; } else { echo "❌ API module is not active\n"; exit(1); } // Test 2: Try to decode the JWT token echo "\nTest 2: Testing JWT token decoding...\n"; try { require_once 'modules/api/third_party/node.php'; require_once 'modules/api/vendor/autoload.php'; use Firebase\JWT\JWT; use Firebase\JWT\Key; $config = require_once 'modules/api/config/jwt.php'; $decoded = JWT::decode($test_token, new Key($config['jwt_key'], $config['jwt_algorithm'])); echo "✅ Token decoded successfully\n"; echo " User: " . ($decoded->user ?? 'N/A') . "\n"; echo " Name: " . ($decoded->name ?? 'N/A') . "\n"; echo " API Time: " . ($decoded->API_TIME ?? 'N/A') . "\n"; } catch (Exception $e) { echo "❌ Token decoding failed: " . $e->getMessage() . "\n"; } // Test 3: Try to access a basic API endpoint echo "\nTest 3: Testing API endpoint access...\n"; // Simulate API request headers $_SERVER['REQUEST_METHOD'] = 'GET'; $_SERVER['HTTP_AUTHTOKEN'] = $test_token; $_SERVER['REQUEST_URI'] = '/api/customers'; // Try to load the API controller try { // Load the API module require_once 'modules/api/api.php'; // Try to instantiate the customers controller $CI->load->library('api_aeiou'); // Load any required libraries echo "✅ API module loaded successfully\n"; echo "✅ Basic API functionality appears to be working\n"; } catch (Exception $e) { echo "❌ API loading failed: " . $e->getMessage() . "\n"; } echo "\n=== API Test Summary ===\n"; echo "If all tests passed above, the API should be working with your token.\n"; echo "You can now test actual API endpoints using tools like:\n"; echo "- Postman\n"; echo "- curl commands\n"; echo "- The API playground at: /api/playground\n"; echo "\nExample curl command:\n"; echo "curl -H \"Authtoken: $test_token\" https://flexinit.nl/portal/api/customers\n"; ?>