How to write code for InCall and AfterCall webhook url for Myoperator
InCall Webhook Myoperator
public function inCallWebhook(Request $request)
{
$data = array();
$data['data'] = json_decode(Request::createFromGlobals()->getContent());
$input = array();
try{
$input['incall_id'] = $data['data']->id;
$input['uid'] = $data['data']->uid;
$input['reference_id'] = $data['data']->reference_id;
$input['company_id'] = $data['data']->company_id;
$input['clid_raw'] = $data['data']->clid_raw;
$input['clid'] = $data['data']->clid;
$input['rdnis'] = $data['data']->rdnis;
$input['call_state'] = $data['data']->call_state;
$input['event'] = $data['data']->event;
$input['status'] = $data['data']->status;
$input['users'] = $data['data']->users;
$input['created'] = $data['data']->created;
$input['call_time'] = $data['data']->call_time;
$calIncallWebhook = new CalIncallWebhook($input);
$calIncallWebhook->save();
}
catch(Exception $ex)
{
$fp = fopen($_SERVER['DOCUMENT_ROOT'] . "/public/incall.txt","w");
//fwrite($fp, Request::createFromGlobals()->getContent());
fwrite($fp, $ex->getMessage());
fclose($fp);
}
return $this->sendResponse($data, 'Successfully');
}
AfterCall Webhook Myoperator
public function afterCallWebhook(Request $request)
{
$data = array();
$data['data'] = json_decode(Request::createFromGlobals()->getContent());
$input = array();
try{
$input['aftercall_id'] = $data['data']->_ai;
$input['company_id'] = $data['data']->_ci;
$input['caller_cr'] = $data['data']->_cr;
$input['caller_cl'] = $data['data']->_cl;
$input['calllocation_se'] = $data['data']->_se;
$input['status_su'] = $data['data']->_su;
$input['call_st'] = $data['data']->_st;
$input['call_et'] = $data['data']->_et;
$input['time_ss'] = $data['data']->_ss;
$input['duration_dr'] = $data['data']->_dr;
$input['calltype_ev'] = $data['data']->_ev;
$input['reference_ri'] = $data['data']->_ri;
$calAftercallWebhook = new CalAftercallWebhook($input);
$calAftercallWebhook->save();
}
catch(Exception $ex)
{
$fp = fopen($_SERVER['DOCUMENT_ROOT'] . "/public/aftercall.txt","w");
//fwrite($fp, Request::createFromGlobals()->getContent());
fwrite($fp, $ex->getMessage());
fclose($fp);
}
return $this->sendResponse($data, 'Successfully');
}
public function InCallWebhookCode(Request $request)
{
$data = array();
$data['data'] = json_decode(Request::createFromGlobals()->getContent());
$fp = fopen($_SERVER['DOCUMENT_ROOT'] . "/public/incall.txt","w");
fwrite($fp, Request::createFromGlobals()->getContent());
fclose($fp);
return $this->sendResponse($data, 'Successfully');
}
public function inCallWebhook(Request $request)
{
$data = array();
$aaaa['raw'] = json_decode(Request::createFromGlobals()->getContent());
$data['data'] = json_decode($aaaa['raw']->message->data);
$fp = fopen($_SERVER['DOCUMENT_ROOT'] . "/public/incall.txt","w");
fwrite($fp, Request::createFromGlobals()->getContent());
OR
fwrite($fp, $aaaa['raw']->message->data);
fclose($fp);
return $this->sendResponse($data, 'Successfully');
}
Discover more from Soa Technology | Aditya Website Development Designing Company
Subscribe to get the latest posts sent to your email.