Question

I have done a Web site using php and which asterisk is used as a Voip system.Now the problem is I want to get the call duration of each call after 'HANG UP'.I googled alot and got an asterisk variable named ${ANSWEREDTIME},but don't know how I can get the value from it and how I can initiate it. Please Help and consider me as new bee to PHP AGI scripting...! Thanks in advance.

Was it helpful?

Solution

Voip-info has a great example of how to write an AGI in PHP. If you look at the function on that page described by the signature 'function execute_agi($command)', you'll see how to make a generic php function to issue commands to asterisk and receive data back.

Once you've done that, you can just put the following code after your Dial statement has returned: $callduration = execute_agi("GET VARIABLE ANSWEREDTIME");

Alternatively, if you build your php script on a PHP asterisk Library (a few are listed here at VOIP-Info) you can use an already tested and feature-filled PHP interface to talk to Asterisk. Good luck!

OTHER TIPS

If I remember correctly, the database has a billsec field which I believe is the call length

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top