$r->addCollectDtmf($cd); $_SESSION['next_goto'] = 'phonemenu'; //$r->addHangup(); } else { if ($_SESSION['next_goto'] == 'phonemenu' && isset($_REQUEST['event']) && $_REQUEST['event'] == 'GotDTMF') { if (isset($_REQUEST['data']) && !empty($_REQUEST['data']) && strlen($_REQUEST['data']) >= 9) { $_SESSION['pref_num'] = $_REQUEST['data']; $r->addPlayText('Please Record Your Message to send!'); //give unique file name for each recording $r->addRecord('filename2', 'wav', '120'); $_SESSION['next_goto'] = 'Record_Status'; } else { $r->addPlayText("you have not given any input please re enter or wrong input"); $cd = new CollectDtmf(); //initiate new collect dtmf object $cd->setMaxDigits(10); $cd->setTermChar('#'); $cd->addPlayText("Please enter number to send message end with hash!"); $r->addCollectDtmf($cd); $_SESSION['next_goto'] = 'phonemenu'; } } else { if ($_REQUEST['event'] == 'Record' && $_SESSION['next_goto'] == 'Record_Status') { //recorded file will be come as url in data param //print parameter data value $r->addPlayText('your recorded audio is '); $_SESSION['record_url'] = $_REQUEST['data']; error_log($_SESSION['record_url']); $r->addPlayAudio($_SESSION['record_url']); $r->addPlayText('Thanks you for calling, we will deliver your message'); } else {
//here i had maintain next_goto as session variable $_SESSION['next_goto'] = 'Menu1'; } 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 {
function press1DTMF() { $cd = new CollectDtmf(); //initiate new collect dtmf object $cd->addPlayText("We will send you and sms for this job, please check within 5 minutes"); $cd->addPlayText("Press 1, to hear more jobs like this"); $cd->addPlayText("Press 2, to hear same job but in different place"); $cd->addPlayText("Press 3, to hear about different job in different place"); $cd->addPlayText("Press 4, to change salary"); $cd->setMaxDigits(1); return $cd; }