I am new to twilio api. In the web application I'm working on, I need to check the completed call or not, and I send the wav file to twiml. If this is completed, I must deduct the user's credit. I am using the following code ...
callMeAction
$AccountSid = "**********************";
$AuthToken = "***************";
$from = '**************';
$to = $_POST['contactno'];
$url = 'http://'.$_SERVER['HTTP_HOST'].'/public/';
$client = new Services_Twilio($AccountSid, $AuthToken);
$call = $client->account->calls->create($from, $to, $url . 'callback.php?number=' . $_POST['contactno'] . '&wav=' . $_POST['wav']);
$msg = urlencode("Connecting... " . $call->sid);
$this->view->msg = $msg;
if($call->status == 'COMPLETED'){
$this->view->msg = $msg;
}
callback.php
<?php
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
?>
<?php if($_REQUEST['wav']){ ?>
<Response>
<Say>A customer at the number <?php echo $_REQUEST['number']?> is calling</Say>
<Dial><?php echo $_REQUEST['number']?></Dial>
<Play><?php echo $_REQUEST['wav'] ;?></Play>
</Response>
<?php } ?>
Please help me ... Thanks in advance. :)
source
share