Programatically get extension status?

Status
Not open for further replies.

Mathias Maes

Customer
Joined
Dec 4, 2017
Messages
33
Reaction score
2
Hello

I want to show the status of extensions on a webpage, is there a way to programatically get the status of an extension?
Language is not very important, whatever works.

Thanks!
 
  • Like
Reactions: VoIPTools
Hi Mathias,

Whether you are talking about the extension's presence status, or the registration status of their phone, the solution is the same. The only way you can get this information is using the 3CX Call Control API and subscribing to the events (actually you could poke 3CX every few seconds but that would be bad coding practice).

Presence is a property on an extension. Unfortunately, when 3CX sends an update event for an extension, you don't know what property has changed. So you have to look at what you have for the current presence, and compare the data that came in the event to see if the presence has changed. If I remember correctly, the status is a number 0-4 (maybe 1-5) which equates to one of the 5 presences.

Whether the extension is registered or not is a little foggy for me at the moment. My assumption is that this is a property of an extension's devices. A device being a phone. It's been a couple years since I poked around for that answer...

Keep in mind that the Call Control API only accepts requests from Localhost, so your web page can't query the API directly. You will have to create a service that monitors events and publishes the results and your web page will have to subscribe to the published events. Yes, this is an ugly can of worms.

Of course, there is the VoIPTools solution which greatly simplifies this whole process of remotely connecting to the Call Control API to subscribe to events and query objects. We have a REST API for working with objects and a SignalR (websockets) API for subscribing to events.
 
  • Like
Reactions: edossantos
I didn't see Ernesto's response before I posted mine. My comment about proper coding practices was NOT directed at his suggestion. While the concern is the same, his approach is far, far simpler to implement than what I suggested.
 
  • Like
Reactions: edossantos
Status
Not open for further replies.

Forum statistics

Threads
112,326
Messages
591,899
Members
165,479
Latest member
Senergia