} if ($_REQUEST['event'] == "Disconnect" || $_REQUEST['event'] == "Hangup") { //when users hangs up at any time in call event=Disconnect // when applicatoin sends hangup event event=Disconnect //if users hang up the call in dial event you will get data ans status params also //$_SESSION['dial_record_url']=$_REQUEST['data']; //$_SESSION['dial_status']=$_REQUEST['status']; exit; } if ($_SESSION['next_goto'] == 'Menu1') { $collectInput = new CollectDtmf(); $collectInput->addPlayText('Welcome to Koo Koo. Are you new to place?', 4); $collectInput->addPlayText('press 1 for entering location, press 2 for nearby places, press 3 for weather details', 4); $collectInput->setMaxDigits('1'); //max inputs to be allowed $collectInput->setTimeOut('4000'); //maxtimeout if caller not give any inputs $r->addCollectDtmf($collectInput); $_SESSION['next_goto'] = 'Menu1_CheckInput'; } else { if ($_REQUEST['event'] == 'GotDTMF' && $_SESSION['next_goto'] == 'Menu1_CheckInput') { //input will come data param //print parameter data value if ($_REQUEST['data'] == '') { //if value null, caller has not given any dtmf //no input handled $r->addPlayText('you have not entered any input'); $_SESSION['next_goto'] = 'Menu1'; } else { if ($_REQUEST['data'] == '1') { $_SESSION['next_goto'] = 'Record_Status';
session_start(); $r = new Response(); if ($_REQUEST['event'] == "NewCall") { $cd = new CollectDtmf(); $cd->setTermChar("#"); $cd->setTimeOut("4000"); $cd->addPlayText("welcome to adder.Please enter your first number.Terminate with hash"); $r->addCollectDtmf($cd); $_SESSION['state'] = "firstNumber"; $r->send(); } else { if ($_REQUEST['event'] == "GotDTMF" && $_SESSION['state'] == "firstNumber") { $first = $_REQUEST['data']; $cd = new CollectDtmf(); $cd->setTermChar("#"); $cd->setTimeOut("4000"); $cd->addPlayText("Please enter the Second number.Terminate with hash"); $_SESSION['firstNumber'] = $first; $_SESSION['state'] = "secondNumber"; $r->addCollectDtmf($cd); $r->send(); } else { if ($_REQUEST['event'] == "GotDTMF" && $_SESSION['state'] == "secondNumber") { $second = $_REQUEST['data']; $total = $_SESSION['firstNumber'] + $second; $r->addPlayText("your total is {$total}"); $r->addHangup(); $r->send(); } } }