sound-effects/test_webhook.php
DJP 4c734e51d4 Initial commit: Sound Effects App
Added complete sound effects application with multiple versions (V1, V2),
configuration files, webhook functionality, and associated assets.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-14 16:04:47 -04:00

116 lines
No EOL
4.6 KiB
PHP

<?php
/**
* Test Webhook Integration for Sound Effects Generator
*
* This script sends a sample webhook with mock data to test the integration
* Run this file directly to test webhook connectivity and data format
*/
// Include the audio webhook processor
require_once 'webhook_processor_audio.php';
// Create a small mock MP3 file (minimal valid MP3 header + silent audio)
function createMockMp3Data() {
// This is a minimal valid MP3 file with about 1 second of silence
// MP3 frame header + minimal audio data
$mp3Header = "\xFF\xFB\x90\x00"; // MP3 frame header (MPEG-1 Layer 3, 128kbps, 44.1kHz, mono)
$mockAudioData = str_repeat("\x00", 1024); // Silent audio data
return $mp3Header . $mockAudioData;
}
echo "🎵 Testing Sound Effects Webhook Integration\n";
echo "==========================================\n\n";
try {
// Initialize webhook processor
$webhookProcessor = new AudioWebhookProcessor([
'client' => 'Oliver Agency - Test',
'user_email' => 'webhook-test@oliver.agency'
]);
echo "✅ Webhook processor initialized\n";
// Test webhook connectivity first
echo "🔗 Testing webhook connectivity...\n";
$connectivityTest = $webhookProcessor->testWebhook();
if ($connectivityTest['success']) {
echo "✅ Webhook endpoint is reachable\n";
echo " Response time: " . $connectivityTest['response_time_ms'] . "ms\n";
echo " HTTP code: " . $connectivityTest['http_code'] . "\n\n";
} else {
echo "❌ Webhook endpoint test failed\n";
echo " HTTP code: " . $connectivityTest['http_code'] . "\n";
echo " Error: " . $connectivityTest['error'] . "\n\n";
}
// Create mock sound generation data
$mockAudioData = createMockMp3Data();
$timestamp = date('Y-m-d_H-i-s');
$testWebhookData = [
'prompt' => 'Test sound: Epic cinematic boom with reverb (WEBHOOK TEST)',
'generation_type' => 'ElevenLabs Sound Effects',
'settings' => [
'prompt' => 'Test sound: Epic cinematic boom with reverb (WEBHOOK TEST)',
'duration_seconds' => 3.5,
'prompt_influence' => 0.7,
'model' => 'elevenlabs-sound-generation',
'test_mode' => true
],
'audio_data' => $mockAudioData,
'client' => 'Oliver Agency - Webhook Test',
'user_email' => 'webhook-test@oliver.agency',
'deliverable_number' => '1000000',
'additional_data' => [
'filename' => 'test_sound_effect_' . $timestamp . '.mp3',
'file_size' => strlen($mockAudioData),
'generation_timestamp' => date('Y-m-d H:i:s'),
'api_endpoint' => 'elevenlabs-sound-generation',
'test_source' => 'webhook_test_script',
'test_description' => 'Mock sound generation for webhook testing'
]
];
echo "📦 Prepared test webhook data:\n";
echo " Prompt: " . $testWebhookData['prompt'] . "\n";
echo " Duration: " . $testWebhookData['settings']['duration_seconds'] . " seconds\n";
echo " Prompt Influence: " . $testWebhookData['settings']['prompt_influence'] . "\n";
echo " Audio Data Size: " . strlen($mockAudioData) . " bytes\n";
echo " Deliverable Number: " . $testWebhookData['deliverable_number'] . "\n\n";
// Send the webhook
echo "🚀 Sending test webhook...\n";
$webhookSuccess = $webhookProcessor->sendGenerationData($testWebhookData);
if ($webhookSuccess) {
echo "✅ Test webhook sent successfully!\n";
echo " Data should now be visible in your webhook automation system\n";
echo " Look for deliverable: " . $testWebhookData['deliverable_number'] . "\n";
} else {
echo "❌ Test webhook failed to send\n";
echo " Check error logs for more details\n";
}
echo "\n📊 Webhook Configuration:\n";
$config = $webhookProcessor->getConfig();
foreach ($config as $key => $value) {
if (is_array($value)) {
echo " $key: " . json_encode($value) . "\n";
} else {
echo " $key: $value\n";
}
}
} catch (Exception $e) {
echo "❌ Test failed with exception: " . $e->getMessage() . "\n";
echo " Stack trace: " . $e->getTraceAsString() . "\n";
}
echo "\n🔍 Next Steps:\n";
echo "1. Check your webhook automation system for the test data\n";
echo "2. Look for deliverable number starting with 'TEST-'\n";
echo "3. Verify all fields are received correctly\n";
echo "4. Check that the audio file (base64 encoded MP3) is properly formatted\n";
echo "\nTest completed at: " . date('Y-m-d H:i:s') . "\n";
?>