I am developing a mobile app with the Twilio Client and I have an implementation question. My app needs to dial a number and when the call is answered play a message. Using Twiml verb can I play a message with to the person that answers the call? Or is this something I need to create a conference to accomplish?
I have tried to use the action url of the Dial to respond with Twiml when the call is answered but it doesn't seem to work. I sometimes get the callback when the call has ended but even that is sporadic.
Here is the php code for calling out:
<?php
include('../Twilio/autoload.php');
include('./config.php');
use Twilio\Twiml;
$response = new Twiml;
if (isset($_REQUEST['To']) && strlen($_REQUEST['To']) > 0) {
$number = htmlspecialchars($_REQUEST['To']);
$dial = $response->dial(array('callerId' => $TWILIO_CALLER_ID,
'action' => 'http://www.example.com/ios/status.php'));
if (preg_match("/^[\d\+\-\(\) ]+$/", $number)) {
$dial->number($number);
} else {
$dial->client($number);
}
} else {
$response->say("Thanks for calling!");
}
header('Content-Type: text/xml');
echo $response;
?>
Thanks