![]() 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
// Test Lyrics API Integration
// This script tests the API.box lyrics functionality
error_reporting(E_ALL);
ini_set('display_errors', 1);
header('Content-Type: text/html; charset=utf-8');
?>
<!DOCTYPE html>
<html>
<head>
<title>Lyrics API Test - SoundStudio Pro</title>
<style>
body { font-family: Arial, sans-serif; margin: 20px; }
.success { color: green; }
.error { color: red; }
.warning { color: orange; }
pre { background: #f5f5f5; padding: 10px; border-radius: 5px; margin: 10px 0; }
.test-section { border: 1px solid #ddd; padding: 15px; margin: 15px 0; border-radius: 5px; }
</style>
</head>
<body>
<h1>🎵 Lyrics API Test</h1>
<?php
$API_KEY = '63edba40620216c5aa2c04240ac41dbd';
$API_BASE = 'https://api.api.box';
echo "<div class='test-section'>";
echo "<h2>🔍 Testing Lyrics Generation</h2>";
// Test 1: Generate lyrics
$lyricsData = [
'prompt' => 'Generate lyrics for a song about hope and dreams',
'model' => 'v3',
'duration' => 30,
'callBackUrl' => 'https://soundstudiopro.com/callback.php'
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $API_BASE . '/api/v1/lyrics');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($lyricsData));
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);
$error = curl_error($ch);
curl_close($ch);
echo "<p><strong>Lyrics Generation Test (HTTP $httpCode):</strong></p>";
if ($error) {
echo "<p class='error'>CURL Error: $error</p>";
} else {
echo "<pre>" . htmlspecialchars($response) . "</pre>";
$responseData = json_decode($response, true);
if ($httpCode == 200 || $httpCode == 201) {
echo "<p class='success'>✅ Lyrics generation working!</p>";
if (isset($responseData['task_id'])) {
echo "<p class='success'>Task ID: " . htmlspecialchars($responseData['task_id']) . "</p>";
// Test 2: Check status of the generated task
echo "<h3>🔍 Checking Task Status</h3>";
$taskId = $responseData['task_id'];
$statusUrl = $API_BASE . '/api/v1/status/' . $taskId;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $statusUrl);
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);
$statusResponse = curl_exec($ch);
$statusHttpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
echo "<p><strong>Status Check (HTTP $statusHttpCode):</strong></p>";
echo "<pre>" . htmlspecialchars($statusResponse) . "</pre>";
$statusData = json_decode($statusResponse, true);
if (isset($statusData['data']['status'])) {
echo "<p class='success'>Status: " . htmlspecialchars($statusData['data']['status']) . "</p>";
if (isset($statusData['data']['lyrics'])) {
echo "<p class='success'>✅ Lyrics found!</p>";
echo "<div style='background: #e8f5e8; padding: 10px; border-radius: 5px;'>";
echo "<h4>Generated Lyrics:</h4>";
echo "<pre>" . htmlspecialchars($statusData['data']['lyrics']) . "</pre>";
echo "</div>";
}
}
}
} else {
echo "<p class='error'>❌ Lyrics generation failed</p>";
}
}
echo "</div>";
echo "<div class='test-section'>";
echo "<h2>🔍 Testing Existing Task Status</h2>";
// Test with a sample task ID (you can replace this with a real one)
$sampleTaskId = 'task_8_0'; // This was mentioned in the error
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $API_BASE . '/api/v1/status/' . $sampleTaskId);
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);
$error = curl_error($ch);
curl_close($ch);
echo "<p><strong>Sample Task Status Check (HTTP $httpCode):</strong></p>";
if ($error) {
echo "<p class='error'>CURL Error: $error</p>";
} else {
echo "<pre>" . htmlspecialchars($response) . "</pre>";
if ($httpCode == 200) {
echo "<p class='success'>✅ Task status check working!</p>";
} else {
echo "<p class='warning'>⚠️ Task not found or other issue</p>";
}
}
echo "</div>";
echo "<div class='test-section'>";
echo "<h2>🔍 API.box Integration Summary</h2>";
echo "<p><strong>Correct API Endpoints:</strong></p>";
echo "<ul>";
echo "<li>Base URL: <code>https://api.api.box</code></li>";
echo "<li>Generate Music: <code>/api/v1/generate</code></li>";
echo "<li>Generate Lyrics: <code>/api/v1/lyrics</code></li>";
echo "<li>Check Status: <code>/api/v1/status/{task_id}</code></li>";
echo "</ul>";
echo "<p><strong>API Key:</strong> <code>63edba40620216c5aa2c04240ac41dbd</code></p>";
echo "<p><strong>Response Format:</strong> Lyrics are typically in <code>data.lyrics</code> or <code>data.text</code></p>";
echo "</div>";
?>
</body>
</html>