Reputation: 323
What I want to do is simply call a list of numbers. If a number do not answer, I will need to call an alternative number for that specific number.
So I have put together the code below, which makes the outbound call. But I have no sample of StatusCallback code that will be called for the status of the call being made and in the StatusCallback, it will call another number if the status was un-answered.
$account_sid = 'Some Value';
$auth_token = 'Some Value';
$client = new \Services_Twilio($account_sid, $auth_token);
$client->account->calls->create('+448008021203', '+441604280111', 'xyz.com/play_msg.html', array(
'Method' => 'GET',
"StatusCallback" => "xyz.com/call_events.php",
"StatusCallbackMethod" => "POST",
"StatusCallbackEvent" => array("answered", "completed"),
'Record' => 'false',
));
Can someone please share existing sample to do this?
Upvotes: 2
Views: 1982
Reputation: 10366
Twilio evangelist here.
In your call_events.php file you're going to check the CallStatus parameter which is passed by Twilio in its HTTP request as a form-encoded parameter. If the value is not "completed" or "queued" start the next call:
$status = $_REQUEST['CallStatus']
if ($status != "completed" || $status!="queued") {
/* start the next call */
}
Hope that helps.
Upvotes: 3