<?php
require_once 'vendor/autoload.php';
use Twilio\TwiML\VoiceResponse;

header('Content-Type: text/xml');

$response = new VoiceResponse();
$toNumber = $_POST['To'] ?? null; // Customer number from client

if ($toNumber) {
    $dial = $response->dial('', ['callerId' => getenv('TWILIO_PHONE_NUMBER')]);
    $dial->number($toNumber); // Dial the customer's phone
} else {
    $response->say('Sorry, no number provided. Ending call.');
    $response->hangup();
}

echo $response;
?>