I'm developing an application with PHP and a Asterisk Server. One of the features of the application is to check the call status (ringing, answered, hung...) of an specific caller ID, so I would like to know how to do this, because I'm trying with a socket and the command status but I think it has to be a better way to do it.
Thanks in advance.
What API are you using to write this program? AMI? AGI? FastAGI? DeadAGI? Call files? There's a lot of ways to get this information.
NOTE: You cannot tell if a channel has been hungup unless you are using call files and/or CDR access.
With the AMI, you can use the Status command (documented here: http://www.voip-info.org/wiki/view/Asterisk+Manager+API+Action+Status).
With the AGI, you will know the status as it is determined by your program. If you are still in your AGI script, then the call is still in progress and already answered.
If you are using call files, and you have the Archive attribute set to 'yes', then once the call has completed then you can check your outoing_done directory (typically /var/lib/asterisk/outgoing_done/) for your call file. When you read the callfile, you'll notice that Asterisk has appended a status at the bottom of the call file, which will tell you the final status of the call.
The BEST way to get this information is by having your PHP script read from the CDR records on your Asterisk server. Have your CDR records log to a MySQL database, then pull records for your call from the database.