Skip to content

Instantly share code, notes, and snippets.

@tjlytle
Created February 27, 2011 00:21
Show Gist options
  • Save tjlytle/845769 to your computer and use it in GitHub Desktop.
Save tjlytle/845769 to your computer and use it in GitHub Desktop.
Sample script to go directly to voicemail.
<?php
require_once 'client.php'; //setup the Twilio rest client and assorted vars
$number = '1235556789'; //the number you're calling
$data = array('From' => $callerID,
'To' => $number,
'Url' => "http://twimlets.com/message?Message%5B0%5D=Voicemail&");
//place both calls
$call1 = $client->request("$version/Accounts/$accountSid/Calls", 'POST', $data);
$call2 = $client->request("$version/Accounts/$accountSid/Calls", 'POST', $data);
sleep(2); //allow the calls to actually start
//assuming the first call got through, the second was sent to voicemail
//so hangup the first call
$client->request("$version/Accounts/$accountSid/Calls/{$call1->ResponseXml->Call->Sid}", POST, array('Status' => 'completed'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment