$_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 { if ($_REQUEST['event'] == 'Dial' && $_SESSION['next_goto'] == 'Dial1_Status') {
$collectInput->setTimeOut('4000'); //maxtimeout if caller not give any inputs $collectInput->setTermChar('#'); $r->addCollectDtmf($collectInput); $_SESSION['next_goto'] = 'conference'; } else { if ($_REQUEST['event'] == "GotDTMF" && $_SESSION['next_goto'] == 'conference') { if ($_REQUEST['data'] == "") { $collectInput = new CollectDtmf(); $collectInput->addPlayText("You have not given any input"); $collectInput->addPlayText('please enter the conference number again followed by hash', 3); $collectInput->setMaxDigits('4'); //max inputs to be allowed $collectInput->setTimeOut('4000'); //maxtimeout if caller not give any inputs $collectInput->setTermChar('#'); $r->addCollectDtmf($collectInput); $_SESSION['next_goto'] = 'conference'; } else { if ($_REQUEST['data'] == $confno[0]) { $r->addPlayText("Please be online while we connect you. Thank you"); $r->addConference($confno[0]); } else { $r->addPlayText("Your input has been not matched with any our conference numbers"); } } } } $r->send(); ?>
require_once "response.php"; 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(); } }