![]() 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/-49eb70c3/ |
<?php
// Test script with correct API format
error_reporting(E_ALL);
ini_set('display_errors', 1);
echo "<h1>🔧 Fixed API Test</h1>";
// Your API key
$API_KEY = '63edba40620216c5aa2c04240ac41dbd';
$API_URL = 'https://api.api.box';
echo "<h2>Testing with Correct Format</h2>";
// Test with the exact format that should work
$createData = [
'prompt' => 'A happy song about danny',
'model' => 'V3_5',
'style' => 'Pop',
'title' => 'Danny Test Song',
'customMode' => true,
'instrumental' => false,
'duration' => 30,
'callBackUrl' => 'https://soundstudiopro.com/callback.php'
];
echo "<p><strong>Request Data:</strong></p>";
echo "<pre style='background: #f0f0f0; padding: 10px;'>";
echo htmlspecialchars(json_encode($createData, JSON_PRETTY_PRINT));
echo "</pre>";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $API_URL . '/api/v1/generate');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($createData));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer ' . $API_KEY,
'Content-Type: application/json',
'User-Agent: MusicStudio-Pro/1.0'
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$error = curl_error($ch);
curl_close($ch);
echo "<p><strong>HTTP Code:</strong> $httpCode</p>";
if ($error) {
echo "<p style='color: red;'><strong>cURL Error:</strong> $error</p>";
} else {
echo "<p style='color: green;'><strong>cURL:</strong> Success</p>";
}
echo "<p><strong>Response:</strong></p>";
echo "<pre style='background: #f0f0f0; padding: 10px; max-height: 200px; overflow-y: auto;'>";
echo htmlspecialchars($response);
echo "</pre>";
// Parse the response
$decoded = json_decode($response, true);
if ($decoded) {
if (isset($decoded['data']['taskId'])) {
$taskId = $decoded['data']['taskId'];
echo "<p style='color: green;'><strong>✅ SUCCESS!</strong> Task created: $taskId</p>";
echo "<p>Your Danny song is now being generated! 🎵</p>";
// Save to database for testing
require_once 'config/database.php';
session_start();
if (!isset($_SESSION['user_id'])) {
// Create a test session
$_SESSION['user_id'] = 2; // Demo user
$_SESSION['user_name'] = 'Demo User';
}
$title = 'Danny Test Song - ' . substr($createData['prompt'], 0, 50);
createMusicTrack($_SESSION['user_id'], $taskId, $title, $createData['prompt'], 'music', 'v3', 30);
echo "<p style='color: green;'><strong>✅ Saved to database!</strong></p>";
} elseif (isset($decoded['error'])) {
echo "<p style='color: red;'><strong>❌ API Error:</strong> " . htmlspecialchars($decoded['error']) . "</p>";
} elseif (isset($decoded['code']) && $decoded['code'] == 531) {
echo "<p style='color: red;'><strong>❌ Generation Failed:</strong> " . htmlspecialchars($decoded['msg']) . "</p>";
} elseif (isset($decoded['code']) && $decoded['code'] == 400) {
echo "<p style='color: red;'><strong>❌ Bad Request:</strong> " . htmlspecialchars($decoded['msg']) . "</p>";
// Try with different parameters
echo "<h3>Trying Alternative Format...</h3>";
$altData = [
'prompt' => 'A happy song about danny',
'model' => 'V3_5',
'instrumental' => false,
'duration' => 30,
'callBackUrl' => 'https://soundstudiopro.com/callback.php'
];
echo "<p><strong>Simplified Request:</strong></p>";
echo "<pre style='background: #f0f0f0; padding: 10px;'>";
echo htmlspecialchars(json_encode($altData, JSON_PRETTY_PRINT));
echo "</pre>";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $API_URL . '/api/v1/generate');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($altData));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer ' . $API_KEY,
'Content-Type: application/json'
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$altResponse = curl_exec($ch);
$altHttpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
echo "<p><strong>Alternative HTTP Code:</strong> $altHttpCode</p>";
echo "<p><strong>Alternative Response:</strong></p>";
echo "<pre style='background: #f0f0f0; padding: 10px; max-height: 200px; overflow-y: auto;'>";
echo htmlspecialchars($altResponse);
echo "</pre>";
$altDecoded = json_decode($altResponse, true);
if ($altDecoded && isset($altDecoded['data']['taskId'])) {
echo "<p style='color: green;'><strong>✅ SUCCESS with simplified format!</strong></p>";
}
}
}
echo "<h2>🔧 Quick Actions:</h2>";
echo "<p><a href='/create.php' style='background: #48bb78; color: white; padding: 0.5rem 1rem; text-decoration: none; border-radius: 5px; margin-right: 1rem;'>🎵 Try Creating Music</a>";
echo "<a href='/find_danny.php' style='background: #667eea; color: white; padding: 0.5rem 1rem; text-decoration: none; border-radius: 5px; margin-right: 1rem;'>🔍 Check Danny Song</a>";
echo "<a href='/dashboard.php' style='background: #764ba2; color: white; padding: 0.5rem 1rem; text-decoration: none; border-radius: 5px;'>🏠 Back to Dashboard</a></p>";
?>