Tuesday, August 28, 2007

[asterisk-users] deadagi and billsec or answeredtime

Hello,
  I want to create php rate script and I'm using Deadagi. But I allways get billsec 0 , or nothing. Can you help me to solve this problem...
My extension.conf:
exten => _123,1,DeadAgi(rate.php)
exten => _123,2,hangup

And my simple test php script rate.php
#!/usr/local/bin/php -q
<?php
include_once (dirname(__FILE__)."/phpagi.php");
$AGI = new AGI();

$AGI->answer();

$AGI->stream_file('demo-thanks');
$AGI->stream_file('vm-goodbye');
   
$AGI->hangup();

$billsec = get_var($AGI,"CDR(billsec)");
debug("Billsec: $billsec", 1);

function debug($string, $level=3) {
    global $AGI;
    $AGI->verbose($string, $level);
}

function get_var( $agi, $value) {
    $r = $agi->get_variable( $value );
   
    if ($r['result'] == 1)     {
        $result = $r['data'];
        return $result;
    }
    else
        return '';
}

?>

No comments:

Post a Comment