My company created callcentre in PHP few years ago and now they need to upgrade it.
I created Vue.js callcentre frontend application and now I need to start connecting it with old PHP. Problem is that I never used PHP before. I mounted my vue app to receive server side events from backend. So whenever someone calls operator from callcentre, it will send event to my vue app. So I can show answer call button but I need to create functionality for it, whenever operator clicks it will answer that call. Same for hang up.
So I created two methods in vue and using axios I am sending post request to php backend.
Code below.
answerCall(){
let channelId;
for(let i in this.getChannels){
channelId = i
}
console.log(channelId);
axios.post("/hzs/answer", channelId)
.then(response => console.warn(response))
.catch(error => {
this.error = error.message;
console.log(error);
});
},
hangUpCall(){
let channelId;
for(let i in this.getChannels){
channelId = i
}
console.log(channelId);
axios.post("/hzs/hangup", channelId)
.then(response => console.warn(response))
.catch(error => {
this.error = error.message;
console.log(error);
});
},
As you can see, I am sending channelId. That is just long random string which tells php who is calling. I am recieving it from event.
My problem is with PHP, because I don’t know how to use it correctly. This is what I have for answering call. It is created by me, before it was in huge switch case so I just copied it and pasted in new file, where I send http request.
<?php
require_once('/var/www/modules/callcentre/functions.inc.php');
require_once('/var/www/modules/callcentre/constants.inc.php');
if(!authorized('callcentre_admin') && !authorized('callcentre_supervizor') && !authorized('callcentre_agent'))
return false;
function call_answer()
{
$channelid = $arg;
if (!preg_match('/^[0-9a-z/.-]+$/Di', $channelid))
$channelid='XXX';
ccSendToDaemon('answer ' . $channelid . ' ' . $uid);
break;
}
header('Content-Type: application/json');
echo json_encode($defaults);
?>
How can I achieve that after sending POST request to php I can trigger “ccSendToDaemon”?
Hope someone will be able to help me. Thank you for reply.