![]() 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/22f7e6c/ |
<?php
session_start();
require_once 'config/database.php';
// Set session for testing
$_SESSION['user_id'] = 1;
$_SESSION['credits'] = 10;
echo "<h1>🎵 CREATE REAL TEST TRACK</h1>";
echo "<p>This will create a real track through the API.Box system...</p>";
// Test data
$test_data = [
'prompt' => 'A cheerful upbeat song about testing the music creation system with happy melodies and positive vibes',
'type' => 'music',
'model_version' => 'V3_5',
'duration' => 20,
'title' => 'Test Track - Real API Creation'
];
echo "<h2>📝 Test Data</h2>";
echo "<p><strong>Prompt:</strong> " . htmlspecialchars($test_data['prompt']) . "</p>";
echo "<p><strong>Duration:</strong> " . $test_data['duration'] . " seconds</p>";
echo "<p><strong>Model:</strong> " . $test_data['model_version'] . "</p>";
// Make API call
echo "<h2>🚀 Making API Call</h2>";
$api_url = 'https://api.api.box/api/v1/generate';
$api_data = [
'prompt' => $test_data['prompt'],
'model' => 'V3_5',
'style' => 'Pop',
'title' => $test_data['title'],
'customMode' => true,
'instrumental' => false,
'duration' => $test_data['duration'],
'callBackUrl' => 'https://soundstudiopro.com/callback.php'
];
$api_key = '63edba40620216c5aa2c04240ac41dbd';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $api_url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($api_data));
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);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$curl_error = curl_error($ch);
curl_close($ch);
echo "<p><strong>HTTP Code:</strong> $http_code</p>";
if ($curl_error) {
echo "<p style='color: red;'>❌ CURL Error: $curl_error</p>";
exit;
}
if ($http_code === 200) {
$api_response = json_decode($response, true);
if ($api_response && isset($api_response['code']) && $api_response['code'] == 200 && isset($api_response['data']['taskId'])) {
$api_task_id = $api_response['data']['taskId'];
echo "<p style='color: green;'>✅ API.Box accepted the request!</p>";
echo "<p><strong>Task ID:</strong> $api_task_id</p>";
// Create track in database
$pdo = getDBConnection();
$stmt = $pdo->prepare("
INSERT INTO music_tracks (user_id, task_id, title, prompt, music_type, model_version, duration, status, created_at)
VALUES (?, ?, ?, ?, ?, ?, ?, 'processing', NOW())
");
$result = $stmt->execute([
$_SESSION['user_id'],
$api_task_id,
$test_data['title'],
$test_data['prompt'],
$test_data['type'],
$test_data['model_version'],
$test_data['duration']
]);
if ($result) {
$track_id = $pdo->lastInsertId();
echo "<p style='color: green;'>✅ Track created in database!</p>";
echo "<p><strong>Track ID:</strong> $track_id</p>";
// Deduct credit
$stmt = $pdo->prepare("UPDATE users SET credits = credits - 1 WHERE id = ?");
$stmt->execute([$_SESSION['user_id']]);
echo "<p style='color: green;'>✅ Credit deducted!</p>";
// Show monitoring options
echo "<h2>📊 Monitor Progress</h2>";
echo "<p>Your track is now being processed by API.Box. You can monitor it here:</p>";
echo "<div style='border: 1px solid #ddd; padding: 20px; margin: 20px 0; border-radius: 10px; background: #f9f9f9;'>";
echo "<h3>🔍 Monitoring Links</h3>";
echo "<p><a href='/get_result.php?taskId=$api_task_id' target='_blank' style='background: #667eea; color: white; padding: 10px 20px; text-decoration: none; border-radius: 5px; margin: 5px; display: inline-block;'>";
echo "📡 Check Status</a></p>";
echo "<p><a href='/library.php' target='_blank' style='background: #48bb78; color: white; padding: 10px 20px; text-decoration: none; border-radius: 5px; margin: 5px; display: inline-block;'>";
echo "📚 View in Library</a></p>";
echo "<p><a href='/test_audio_player.php' target='_blank' style='background: #764ba2; color: white; padding: 10px 20px; text-decoration: none; border-radius: 5px; margin: 5px; display: inline-block;'>";
echo "🎵 Test Audio Player</a></p>";
echo "</div>";
// Show expected workflow
echo "<h2>🔄 Expected Workflow</h2>";
echo "<ol>";
echo "<li>✅ Track submitted to API.Box</li>";
echo "<li>⏳ API.Box processes the request (usually 2-5 minutes)</li>";
echo "<li>📞 API.Box calls our callback.php when complete</li>";
echo "<li>🎵 Track appears in your library with audio URL</li>";
echo "<li>🎧 You can play and download the track</li>";
echo "</ol>";
echo "<h2>🎯 Next Steps</h2>";
echo "<p>1. <strong>Wait 2-5 minutes</strong> for API.Box to process your track</p>";
echo "<p>2. <strong>Check the status</strong> using the links above</p>";
echo "<p>3. <strong>Visit your library</strong> to see the completed track</p>";
echo "<p>4. <strong>Test the audio player</strong> to verify it works</p>";
} else {
echo "<p style='color: red;'>❌ Failed to create track in database</p>";
}
} else {
echo "<p style='color: red;'>❌ API.Box returned an error</p>";
echo "<p><strong>Response:</strong> " . htmlspecialchars($response) . "</p>";
}
} else {
echo "<p style='color: red;'>❌ HTTP Error: $http_code</p>";
echo "<p><strong>Response:</strong> " . htmlspecialchars($response) . "</p>";
}
echo "<div style='text-align: center; margin-top: 40px;'>";
echo "<a href='/create_music.php' style='background: #48bb78; color: white; padding: 12px 24px; text-decoration: none; border-radius: 8px; margin: 0 10px; font-weight: bold;'>";
echo "🎵 Create Another Track</a>";
echo "<a href='/library.php' style='background: #667eea; color: white; padding: 12px 24px; text-decoration: none; border-radius: 8px; margin: 0 10px; font-weight: bold;'>";
echo "📚 View Library</a>";
echo "<a href='/dashboard.php' style='background: #764ba2; color: white; padding: 12px 24px; text-decoration: none; border-radius: 8px; margin: 0 10px; font-weight: bold;'>";
echo "🏠 Dashboard</a>";
echo "</div>";
?>