The Voicent PHP IVR module contains the following functions:
call_ivr <phoneno> <appname> <selfdelete>
call_ivr('123-4567', 'reminderApp', 1)Make a call to phone number '123-4567' and use 'reminderApp' on the gateway for call interaction. You can use call_status_responses to get the call status and responses, or use call_remove to remove the call record.
call_status_response <reqId> <responses>
$responses = array();Use your responses array with the function.
$status = call_status('123-4567', $responses)
<?php
class Voicent
{
var $host = "localhost";
var $port = 8155;
...
function call_ivr($phoneno, $appname, $selfdelete)
{
$body = "info=" . urlencode("call " .
$phoneno) . "&";
$body .= "phoneno=" .
urlencode($phoneno) . "&";
$body .= "firstocc=10&";
$body .= "startapp=" . urlencode($appname)
. "&";
$body .= "selfdelete=" . $selfdelete;
return $this->_call_now($body);
}
function call_status_response($reqId, &$responses)
{
$headers = "GET /ocall/callstatusHandler.jsp?reqid="
. $reqId . " HTTP/1.1\r\n" .
"User-Agent: Mozilla/4.0\r\n" .
"Host: " . $this->host . "\r\n" .
"\r\n";
if (! ($sock = fsockopen($this->host,
$this->port, $errno, $errstr))) {
echo $errstr;
return false;
}
fwrite($sock, $headers,
strlen($headers));
$status = "";
while ($line = fgets($sock, 4096)) {
if ($line == '')
continue;
$rcarr = explode("^", $line);
// call responses is the 9th field
$resparr = explode("|", $rcarr[8]);
foreach ($resparr as $resp) {
// each is a name value pair
$nvarr = explode("=", $resp);
$key = $nvarr[0];
$value = $nvarr[1];
$responses[$key] = $value;
}
// call status is the 3rd field
if ($rcarr[2] == "made")
$status = "Call Make";
if ($rcarr[2] == "failed")
$status = "Call Failed";
break;
}
fclose($sock);
return $status;
}
......
}
?>