Hi navaismo,
I am pretty close to make it work according to your code. In the extensions.conf file I put your code
and change the next line replacing 1 to n.
exten =>h,1,AGI(updatecrm.php)
exten => h,n,Macro(hangupcall)
However, in my agi file sig_handler only catch the hangup If the call is hung by the receiver. But If callee hangs up No hangup signal is passed.I would be grateful If you tell me how to write the code so that It works for both caller and receiver.
See the CLI plz.
If receiver hangsup
AGI Tx >> agi_request: updatecrm.php
AGI Tx >> agi_channel: SIP/405-092cd048
AGI Tx >> agi_language: en
AGI Tx >> agi_type: SIP
AGI Tx >> agi_uniqueid: 1268306924.278
AGI Tx >> agi_callerid: 405
AGI Tx >> agi_calleridname: Agent405
AGI Tx >> agi_callingpres: 0
AGI Tx >> agi_callingani2: 0
AGI Tx >> agi_callington: 0
AGI Tx >> agi_callingtns: 0
AGI Tx >> agi_dnid: 403
AGI Tx >> agi_rdnis: unknown
AGI Tx >> agi_context: macro-dial
AGI Tx >> agi_extension: h
AGI Tx >> agi_priority: 1
AGI Tx >> agi_enhanced: 0.0
AGI Tx >> agi_accountcode:
AGI Tx >>
AGI Rx << VERBOSE "uniqueid: 1268306924.278" 3
-- agitest.php: uniqueid: 1268306924.278
AGI Tx >> 200 result=1
AGI Rx << VERBOSE "" 3
[color=#FF0000][b] -- agitest.php:
AGI Tx >> 200 result=1
AGI Rx << HANGUP SIP/405-092cd048
AGI Tx >> 200 result=1[/b][/color]
== Spawn h extension (macro-dial, h, 1) exited non-zero on 'SIP/405-092cd048'
== Spawn extension (macro-dial, s, 7) exited non-zero on 'SIP/405-092cd048' in macro 'dial'
== Spawn extension (macro-exten-vm, s, 9) exited non-zero on 'SIP/405-092cd048' in macro 'exten-vm'
== Spawn extension (from-internal, 403, 1) exited non-zero on 'SIP/405-092cd048'
If caller hangs up
AGI Tx >> agi_request: agitest.php
AGI Tx >> agi_channel: SIP/405-092cd048
AGI Tx >> agi_language: en
AGI Tx >> agi_type: SIP
AGI Tx >> agi_uniqueid: 1268307602.280
AGI Tx >> agi_callerid: 405
AGI Tx >> agi_calleridname: Agent405
AGI Tx >> agi_callingpres: 0
AGI Tx >> agi_callingani2: 0
AGI Tx >> agi_callington: 0
AGI Tx >> agi_callingtns: 0
AGI Tx >> agi_dnid: 403
AGI Tx >> agi_rdnis: unknown
AGI Tx >> agi_context: macro-dial
AGI Tx >> agi_extension: h
AGI Tx >> agi_priority: 1
AGI Tx >> agi_enhanced: 0.0
[color=#FF0000]AGI Tx >> agi_accountcode:
AGI Tx >> I>
== Spawn h extension (macro-dial, h, 1) exited non-zero on 'SIP/405-092cd048'[/color] == Spawn extension (macro-dial, s, 7) exited non-zero on 'SIP/405-092cd048' in macro 'dial'
== Spawn extension (macro-exten-vm, s, 9) exited non-zero on 'SIP/405-092cd048' in macro 'exten-vm'
== Spawn extension (from-internal, 403, 1) exited non-zero on 'SIP/405-092cd048'
My little php snipped
#!/usr/bin/php -q
<?php
declare(ticks = 1);
pcntl_signal(SIGHUP, "sig_handler");
require('/var/lib/asterisk/agi-bin/phpagi.php');
$agi = new AGI();
$uniqueid = $agi->request['agi_uniqueid'];
$callerid = $agi->request['agi_callerid'];
$channel = $agi->request['agi_channel'];
$agi->verbose("uniqueid: ".$uniqueid ."\n",3);
$agi->hangup($channel);
exit(0);
function sig_handler($signo)
{
GLOBAL $uniqueid,$callerid;
//query asterisk database
$conn1 = mysql_connect("localhost", "root", "eLaStIx.2oo7");
mysql_select_db("asteriskcdrdb", $conn1);
-
-
//update crm database
-
exit(0);//not sure need this or not.
}
Thanking you.