Is anyway to get DIALSTATUS after caller hangup?

Asterisk ver:1.8.11

I do not know if DeadAgi() work on ver 1.8.11?

I use this:

exten => _X.,1,DeadAGI(dtmf.php)


PHP CODE

$agi->exec_dial(“SIP/9001”);

$dialstatus = $agi->get_variable(“DIALSTATUS”,true);
$agi->verbose($dialstatus);
$answeredtime = $agi->get_variable(“ANSWEREDTIME”,true); // 获取通话时间长度
$agi->verbose($answeredtime);


BUT if Caller hangup first,My PHP will stop before :$dialstatus = $agi->get_variable(“DIALSTATUS”,true);


<SIP/9002-00000047>AGI Tx >>
<SIP/9002-00000047>AGI Rx << EXEC Dial SIP/9001/
– AGI Script Executing Application: (Dial) Options: (SIP/9001/)
== Using SIP RTP CoS mark 5
– Called SIP/9001/
– SIP/9001-00000048 is ringing
<SIP/9002-00000047>AGI Tx >> 200 result=-1
– <SIP/9002-00000047>AGI Script dtmf.php completed, returning 4
== Spawn extension (demo, 9001, 1) exited non-zero on ‘SIP/9002-00000047’

=======================================

Is anyway to get DIALSTATUS and ANSWEREDTIME after caller hangup.

THANKS!!!

Hi,

You can prevent your PHP script from terminating by adding this under the <?php line
pcntl_signal(SIGHUP, SIG_IGN);
This way your php script will work even after the call ends.

The phpagi command Get_Variable is like the READ application in asterisk. So you are using in worng way.

Its better if you use the DIALSTATUS variable whitin dialplan and then send as argument in your agi.