![]() 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/-1f7b4b39/ |
<?php
session_start();
// Enable error reporting
error_reporting(E_ALL);
ini_set('display_errors', 1);
echo "<h2>Debug API Test</h2>";
// Check if user is logged in
if (!isset($_SESSION['user_id'])) {
echo "<p style='color: red;'>❌ User not logged in</p>";
echo "<p>Session data: " . print_r($_SESSION, true) . "</p>";
exit;
}
echo "<p style='color: green;'>✅ User logged in: " . $_SESSION['user_id'] . "</p>";
// Test database connection
try {
require_once 'config/database.php';
$pdo = getDBConnection();
echo "<p style='color: green;'>✅ Database connection successful</p>";
} catch (Exception $e) {
echo "<p style='color: red;'>❌ Database error: " . $e->getMessage() . "</p>";
exit;
}
// Test user credits
try {
$stmt = $pdo->prepare("SELECT credits FROM users WHERE id = ?");
$stmt->execute([$_SESSION['user_id']]);
$user = $stmt->fetch();
if ($user) {
echo "<p style='color: green;'>✅ User credits: " . $user['credits'] . "</p>";
} else {
echo "<p style='color: red;'>❌ User not found in database</p>";
exit;
}
} catch (Exception $e) {
echo "<p style='color: red;'>❌ Error checking credits: " . $e->getMessage() . "</p>";
exit;
}
// Test API.Box connection
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,
'callBackUrl' => 'https://soundstudiopro.com/callback.php'
];
echo "<p>Testing API endpoint: $api_url</p>";
echo "<p>Test data: " . json_encode($test_data, JSON_PRETTY_PRINT) . "</p>";
$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',
'User-Agent: SoundStudioPro-Music/2.0'
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
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>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 successful</p>";
}
echo "<p>Response: " . htmlspecialchars($response) . "</p>";
// Test JSON parsing
$api_result = json_decode($response, true);
if ($api_result === null) {
echo "<p style='color: red;'>❌ JSON parsing failed</p>";
} else {
echo "<p style='color: green;'>✅ JSON parsing successful</p>";
echo "<p>Parsed response: " . print_r($api_result, true) . "</p>";
}
echo "<h3>Test Complete</h3>";
?>