Ajit Panday
Update dependencies and Hugging Face configuration
7d72bcf
<?php
require_once __DIR__ . '/../config/config.php';
require_once __DIR__ . '/Database.php';
require_once __DIR__ . '/WebhookHandler.php';
// Set headers
header('Content-Type: application/json');
header('Access-Control-Allow-Origin: ' . ALLOW_ORIGIN);
header('Access-Control-Allow-Methods: POST');
header('Access-Control-Allow-Headers: Content-Type, X-API-Key');
// Handle preflight requests
if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') {
http_response_code(200);
exit();
}
// Only allow POST requests
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
http_response_code(405);
echo json_encode(['error' => 'Method not allowed']);
exit();
}
try {
// Initialize webhook handler
$handler = new WebhookHandler();
// Process the webhook
$result = $handler->process();
// Return success response
http_response_code(200);
echo json_encode([
'success' => true,
'message' => 'Call record processed successfully',
'call_id' => $result['call_id'] ?? null
]);
} catch (Exception $e) {
// Log error
error_log("Webhook Error: " . $e->getMessage());
// Return error response
http_response_code(500);
echo json_encode([
'success' => false,
'error' => 'Internal server error'
]);
}