Search code examples
httpurlvoipasteriskcdr

Collect Asterisk cdr records by http post


I'm using Asterisk and want to collect cdr records. I searched for a while, and found that there are already modules which we can use to collect cdr records into CSV files or MySQL.

I'm wondering that whether there is already a module which let me collect cdr records by http post. So that when a call finished, Asterisk will post cdr records to a predefined URL.

Thanks in advanced.


Solution

  • I don't know such a module, but you could execute an Application on Hangup.

    You could use the function ${CURL(url[,post-data])}:

    exten => h,n,Set(result=${CURL(http://SERVER/cdr.php?\
                 cdranswer=${CDR(answer)}&exten=${EXTEN}&cidnum=${CALLERID(num)})}) 
    exten => h,n,Noop(${result}) 
    

    Another Approach is to execute a Script on Hangup:

    exten => h,n,System('php -f /opt/scripts/cdr.php \
                            ${CallerID(num)} ${EXTEN} "${CDR(answer)}" ${EPOCH}');
    

    Maybe you could also use ${CDR(billsec)}.