![]() Server : Apache/2 System : Linux server-15-235-50-60 5.15.0-164-generic #174-Ubuntu SMP Fri Nov 14 20:25:16 UTC 2025 x86_64 User : gositeme ( 1004) PHP Version : 8.2.29 Disable Function : exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname Directory : /home/gositeme/.cursor-server/data/User/History/42ebffdd/ |
<?php
// Enable error reporting
error_reporting(E_ALL);
ini_set('display_errors', 1);
echo "<h2>Simple API Test</h2>";
// Test 1: Basic PHP functionality
echo "<p>✅ PHP is working</p>";
// Test 2: Session functionality
session_start();
echo "<p>✅ Sessions are working</p>";
// Test 3: Database connection
try {
require_once 'config/database.php';
$pdo = getDBConnection();
echo "<p>✅ Database connection successful</p>";
// Test 4: Check if users table exists
$stmt = $pdo->query("SELECT COUNT(*) FROM users");
$user_count = $stmt->fetchColumn();
echo "<p>✅ Users table exists with $user_count users</p>";
// Test 5: Check if music_tracks table exists
$stmt = $pdo->query("SELECT COUNT(*) FROM music_tracks");
$track_count = $stmt->fetchColumn();
echo "<p>✅ Music tracks table exists with $track_count tracks</p>";
} catch (Exception $e) {
echo "<p style='color: red;'>❌ Database error: " . $e->getMessage() . "</p>";
exit;
}
// Test 6: cURL functionality
if (function_exists('curl_init')) {
echo "<p>✅ cURL is available</p>";
} else {
echo "<p style='color: red;'>❌ cURL is not available</p>";
}
// Test 7: JSON functionality
if (function_exists('json_encode')) {
echo "<p>✅ JSON functions are available</p>";
} else {
echo "<p style='color: red;'>❌ JSON functions are not available</p>";
}
// Test 8: Test a simple API.Box request
echo "<h3>Testing API.Box Connection</h3>";
$api_url = 'https://api.api.box/api/v1/generate';
$api_key = '63edba40620216c5aa2c04240ac41dbd';
$test_data = [
'prompt' => 'Test music generation',
'model' => 'chirp-v3-5',
'style' => 'Pop',
'title' => 'Test Track',
'customMode' => false,
'instrumental' => false,
'duration' => 30
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $api_url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($test_data));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer ' . $api_key,
'Content-Type: application/json'
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$curl_error = curl_error($ch);
curl_close($ch);
echo "<p>API URL: $api_url</p>";
echo "<p>HTTP Code: $http_code</p>";
if ($curl_error) {
echo "<p style='color: red;'>❌ cURL Error: $curl_error</p>";
} else {
echo "<p style='color: green;'>✅ cURL request completed</p>";
}
echo "<p>Response: " . htmlspecialchars($response) . "</p>";
// Test 9: Check if the response is valid JSON
$api_result = json_decode($response, true);
if ($api_result === null && $response !== '') {
echo "<p style='color: red;'>❌ Response is not valid JSON</p>";
} else {
echo "<p style='color: green;'>✅ Response is valid JSON</p>";
}
echo "<h3>Test Complete</h3>";
?>