{ if (isset($arr[$key])) { return $arr[$key]; } return ''; } function sendCallDoneInfo($request) { $callduration = getValueFromArray($request, 'callduration'); $status = getValueFromArray($request, 'status'); $data = getValueFromArray($request, 'data'); $message = getValueFromArray($request, 'message'); } if (isset($_REQUEST['event']) && $_REQUEST['event'] == 'NewCall') { $r->addPlayText("Please wail while we connecting"); $r->addDial($customerNumber, true); //phone number to dial } elseif (isset($_REQUEST['event']) && $_REQUEST['event'] == 'Dial') { sendCallDoneInfo($_REQUEST); if ($_REQUEST['status'] == 'answered') { $r->addPlayText("dialled number is answered"); } else { $r->addPlayText("dialled number is not answered"); } $r->addHangup(); } elseif (isset($_REQUEST['event']) && $_REQUEST['event'] == 'Hangup') { if (isset($_REQUEST['process']) && $_REQUEST['process'] == 'dial') { sendCallDoneInfo($_REQUEST); } else { if (isset($_REQUEST['process']) && $_REQUEST['process'] == 'none') { sendCallInfo($_REQUEST);
curl_close($ch); } function sendCallDoneInfo($request, $stage) { global $apiurl; global $agentid; $callduration = getValueFromArray($request, 'callduration'); $status = getValueFromArray($request, 'status'); $recordurl = getValueFromArray($request, 'data'); $message = getValueFromArray($request, 'message'); $data = array("callduration" => $callduration, "status" => $status, "recordurl" => $data, "message" => $message, "stage" => $stage, "agent" => $agentid, "type" => "nextcall"); curlPost($apiurl . '/api/agent.php', $data); } if (isset($_REQUEST['event']) && $_REQUEST['event'] == 'NewCall') { $r->addPlayText("Please wail while we connecting"); $r->addDial($customerNumber, true, "1000", 10000, 'default', 'no', '+911130715347'); //phone number to dial } elseif (isset($_REQUEST['event']) && $_REQUEST['event'] == 'Dial') { sendCallDoneInfo($_REQUEST, $STAGE1); if ($_REQUEST['status'] == 'answered') { //$r->addPlayText("dialled number is answered"); } else { $r->addPlayText("dialled number is not answered"); } $r->addHangup(); } elseif (isset($_REQUEST['event']) && $_REQUEST['event'] == 'Hangup') { if (isset($_REQUEST['process']) && $_REQUEST['process'] == 'dial') { sendCallDoneInfo($_REQUEST, $STAGE2); } else { if (isset($_REQUEST['process']) && $_REQUEST['process'] == 'none') { sendCallDoneInfo($_REQUEST, $STAGE3);