Tropo Dialer POC
Quick and dirty Tropo dialer script triggered by a website with a list of numbers and a message to play. Built as a POC
Tropo Script
<?php
call('+1'.$dnis, array("from" => "+1".$ani));
$confirm = "0";
while ( $confirm == "0" && $currentCall->isActive() ) {
$result = ask( $prompt,
array( "choices" => "confirm( 1, confirm)") );
if ($result->name=="choice")
{
if ($result->value == "confirm")
{
say( "Message receipt Confirmed." );
$confirm = "1";
}
}
}
hangup();
?>
Server Script
<?php
echo<<<EOF
<html>
<head>
<title>Outbound Dialer - Tropo</title>
</head>
<body bgcolor=#ffffff text=#000000>
EOF;
if ( ! isset($_POST['dnis_list']) ) {
echo<<<EOF
<form method=post>
<input type=text name=ani placeholder="10 digit Caller ID Number"><br>
<textarea name=prompt cols=100 rows=3>Enter what you want to say here...
</textarea><br>
<textarea name=dnis_list cols=13 rows=20>Enter a list of 10 digit US numbers to call
</textarea><br>
<input type=submit value="Start Calling">
</form>
EOF;
} else {
$ani = $_POST['ani'];
$dnis_array = preg_split('/[^0-9]/',$_POST['dnis_list']);
$prompt = $_POST['prompt'];
$tropo_token = "token=<token>";
foreach ( $dnis_array as $dnis ) {
if ( $dnis > 1 ) {
$tropo_url = "https://api.tropo.com/1.0/sessions?action=create&".$tropo_token."&dnis=".$dnis."&ani=".$ani."&prompt=".urlencode($prompt);
$curl = curl_init();
// Set some options - we are passing in a useragent too here
curl_setopt_array($curl, array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => $tropo_url,
CURLOPT_USERAGENT => 'calling Name'
));
// Send the request & save response to $resp
$response = curl_exec($curl);
// Close request to clear up some resources
curl_close($curl);
}
}
echo "Calls sent. There would be a link to a url to check the status of the calls if that were something I felt like doing";
}
echo "</body>\n";
echo "</html>";
?>