![]() 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/domains/gocodeme.com/public_html/BACKUP/ |
<?php
// Test file to verify API functionality
header('Content-Type: text/html; charset=utf-8');
echo "<h1>MusicStudio Pro API Test</h1>";
// Test the API endpoint
$testData = [
'action' => 'music',
'prompt' => 'A peaceful acoustic guitar melody with soft piano accompaniment',
'model' => 'v3',
'duration' => 30
];
echo "<h2>Testing API with data:</h2>";
echo "<pre>" . json_encode($testData, JSON_PRETTY_PRINT) . "</pre>";
// Make the API call
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['REQUEST_URI']) . '/api.php');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($testData));
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$error = curl_error($ch);
curl_close($ch);
echo "<h2>API Response (HTTP $httpCode):</h2>";
if ($error) {
echo "<p style='color: red;'>cURL Error: $error</p>";
} else {
echo "<pre>" . htmlspecialchars($response) . "</pre>";
$result = json_decode($response, true);
if ($result) {
if (isset($result['success']) && $result['success']) {
echo "<p style='color: green;'>✅ API is working correctly!</p>";
} else {
echo "<p style='color: orange;'>⚠️ API returned an error: " . ($result['error'] ?? 'Unknown error') . "</p>";
}
} else {
echo "<p style='color: red;'>❌ Failed to parse JSON response</p>";
}
}
// Test API directly (for debugging)
echo "<h2>Direct API Test:</h2>";
$API_KEY = '63edba40620216c5aa2c04240ac41dbd';
$API_URL = 'https://api.box';
$testSunoData = [
'prompt' => 'A peaceful acoustic guitar melody with soft piano accompaniment',
'model' => 'v3',
'duration' => 30
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $API_URL . '/music/generate');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($testSunoData));
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);
$apiResponse = curl_exec($ch);
$apiHttpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$apiError = curl_error($ch);
curl_close($ch);
echo "<h3>API Response (HTTP $apiHttpCode):</h3>";
if ($apiError) {
echo "<p style='color: red;'>API cURL Error: $apiError</p>";
} else {
echo "<pre>" . htmlspecialchars($apiResponse) . "</pre>";
$apiResult = json_decode($apiResponse, true);
if ($apiResult) {
if (isset($apiResult['id'])) {
echo "<p style='color: green;'>✅ API is working! Generated ID: " . $apiResult['id'] . "</p>";
} else {
echo "<p style='color: orange;'>⚠️ API response: " . json_encode($apiResult) . "</p>";
}
} else {
echo "<p style='color: red;'>❌ Failed to parse API JSON response</p>";
}
}
echo "<hr>";
echo "<p><a href='musicstudio.html'>← Back to MusicStudio Pro</a></p>";
?>