V20 Call Control API

Robking

Customer
Joined
Jan 12, 2023
Messages
4
Reaction score
3
Version 20.0 Update 4 (Build 487 Release)

Good morning,

https://www.3cx.com/docs/call-control-api-endpoints/

I am trying to connect to the new Call Control API, but I its not that cleat how to Authenticate.

I have created an app on the admin

I am using curl php. looking at some documentation it says to use https://???.3cx.uk/api/connect?appId= but i get 404 error.

I have managed to connect and use the xapi system, with no issues.

The make call function on xapi does not work well, as it will ring only on one device. I see that on call-control I should be able to get a list of devices per user so the user can select the device.

has anyone got the authentication working?
 
Hello, it seems like you are trying to use the authorization endpoint from the example repository's backend server, instead of the PBX.

If you want to authenticate and obtain a token, please refer to the following endpoint:

Authorization Endpoint Documentation

please use your appId and secret for appropriate body parameters,
'grant_type' should be 'client_credentials'.

Once you have the token, you can use it to establish a WebSocket connection or perform other call control operations as needed.

WebSocket Connection Endpoint Documentation

Best regards,
 
Thank you for your reply.

I have just managed to get it working, I was already getting the token for the xapi, i thought it was 2 different systems.
 
Hello, please share the curl request sampel to connect to the websocket request
 
Hello, please share the curl request sampel to connect to the websocket request
Can't use CURL to do Websocket lol it's not the same protocol.
 
  • Like
Reactions: N_G
sorry meant the request body for websocket
 
  • Like
Reactions: N_G
I’ve checked but have not yet managed to get so far and that is why I posted on the forum.
 
Good morning,

I know the manuals are not always that helpful.

this is the php code i use to make a call, I hope this is helpful to you.

$call_details = array(
'reason' => 'call',
'destination' => $number,
'timeout' => $timeout,
);

$url = "https://zzzzzzz.3cx.uk/callcontrol/$ext/devices/$deviceid/makecall";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($call_details));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/json; charset=utf-8',
'Authorization: Bearer '.$token
]);
$response = curl_exec($ch);
 
Hello thank you. I did manage to make a call successfully, what I am not struggling with is getting call statuses. Preferably in realtime. So that if we doing dialing we check status of one call before placing another one.
 

Members Online Now

No members online now.

Forum statistics

Threads
111,843
Messages
589,327
Members
164,679
Latest member
SamadMYK