![]() 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/soundstudiopro.com/private_html/utils/ |
<?php
header('Content-Type: text/html; charset=utf-8');
?>
<!DOCTYPE html>
<html>
<head>
<title>API Workflow Test - MusicStudio Pro</title>
<style>
body { font-family: Arial, sans-serif; margin: 20px; }
.success { color: green; }
.error { color: red; }
.warning { color: orange; }
.info { color: blue; }
pre { background: #f5f5f5; padding: 10px; border-radius: 5px; }
.step { margin: 10px 0; padding: 10px; border-left: 4px solid #ddd; }
</style>
</head>
<body>
<h1>🔧 API Workflow Test</h1>
<?php
$API_KEY = '63edba40620216c5aa2c04240ac41dbd';
$API_URL = 'https://api.box';
echo "<h2>Step 1: Test API Connection</h2>";
// Test basic connection
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $API_URL);
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);
if ($error) {
echo "<p class='error'>❌ Connection Error: $error</p>";
exit;
} else {
echo "<p class='success'>✅ API reachable (HTTP $httpCode)</p>";
}
echo "<h2>Step 2: Test Music Generation Workflow</h2>";
// Step 1: Create music generation task
echo "<div class='step'>";
echo "<h3>Creating Music Generation Task...</h3>";
$createData = [
'prompt' => 'A peaceful acoustic guitar melody',
'model' => 'v3',
'duration' => 10
];
$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($createData));
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);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
echo "<p><strong>HTTP Code:</strong> $httpCode</p>";
echo "<p><strong>Response:</strong></p>";
echo "<pre>" . htmlspecialchars($response) . "</pre>";
$result = json_decode($response, true);
if ($result && isset($result['id'])) {
echo "<p class='success'>✅ Task created successfully! ID: " . $result['id'] . "</p>";
$taskId = $result['id'];
} else {
echo "<p class='error'>❌ Failed to create task</p>";
echo "<p><strong>Error:</strong> " . ($result['error'] ?? 'Unknown error') . "</p>";
exit;
}
echo "</div>";
// Step 2: Poll for completion
echo "<div class='step'>";
echo "<h3>Polling for Task Completion...</h3>";
$maxAttempts = 10; // Reduced for testing
$completed = false;
for ($attempt = 1; $attempt <= $maxAttempts; $attempt++) {
echo "<p>Attempt $attempt/$maxAttempts...</p>";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $API_URL . '/music/' . $taskId);
curl_setopt($ch, CURLOPT_HTTPGET, true);
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);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
echo "<p><strong>Status Check (HTTP $httpCode):</strong></p>";
echo "<pre>" . htmlspecialchars($response) . "</pre>";
$result = json_decode($response, true);
if ($result && isset($result['status'])) {
if ($result['status'] === 'complete') {
echo "<p class='success'>✅ Task completed successfully!</p>";
$completed = true;
break;
} elseif ($result['status'] === 'failed') {
echo "<p class='error'>❌ Task failed: " . ($result['error'] ?? 'Unknown error') . "</p>";
break;
} else {
echo "<p class='info'>⏳ Task still processing... Status: " . $result['status'] . "</p>";
}
} else {
echo "<p class='warning'>⚠️ Unexpected response format</p>";
}
if ($attempt < $maxAttempts) {
echo "<p>Waiting 3 seconds before next check...</p>";
sleep(3);
}
}
if (!$completed) {
echo "<p class='error'>❌ Task did not complete within expected time</p>";
}
echo "</div>";
// Step 3: Show final results
if ($completed) {
echo "<div class='step'>";
echo "<h3>Final Results:</h3>";
echo "<pre>" . json_encode($result, JSON_PRETTY_PRINT) . "</pre>";
if (isset($result['audio_url'])) {
echo "<p class='success'>🎵 Audio URL: " . $result['audio_url'] . "</p>";
echo "<audio controls style='width: 100%; max-width: 500px;'>";
echo "<source src='" . $result['audio_url'] . "' type='audio/mpeg'>";
echo "Your browser does not support the audio element.";
echo "</audio>";
}
if (isset($result['lyrics'])) {
echo "<p class='success'>📝 Lyrics generated!</p>";
echo "<div style='background: #f9f9f9; padding: 15px; border-radius: 5px;'>";
echo "<h4>Generated Lyrics:</h4>";
echo "<p style='white-space: pre-wrap;'>" . htmlspecialchars($result['lyrics']) . "</p>";
echo "</div>";
}
echo "</div>";
}
?>
<hr>
<h2>🔗 Quick Links</h2>
<ul>
<li><a href="musicstudio.html">🎵 MusicStudio Pro</a></li>
<li><a href="diagnostic.php">🔧 Server Diagnostic</a></li>
<li><a href="fix_permissions.php">🔧 Fix Permissions</a></li>
</ul>
</body>
</html>