It is some times necessary to pass a argument to asterisk dialplan and read that variable or value
from another script.In PHP-AGI this thing is done as follows
Passing an argument or variable value is setting it in the “orginate application”.
eg:
<?php
require(’phpagi/phpagi.php’);
require_once(’phpagi/phpagi-asmanager.php’);
$number = ‘9946236111′;
$asm = new AGI_AsteriskManager();
if($asm->connect())
{
$call = $asm->send_request(’Originate’,
array(’Channel’=>”SS7/9946236329″,
‘Context’=>’demospeech’,
‘Priority’=>1,
‘Callerid’=>$number,
‘Async’=>’true’,
‘Variable’=>’cnum=9947000XXX′)); //asterisk variable setting as “9947000XXX″
$asm->disconnect();
}
?>
The “cunum variable is accepted in asterisk as
[demospeech]
exten => s,1,AGI(incoming.php|${CNUM}) //here “{CNUM}” will store the variable value.
To get that value in another script is done by as follows
#!/usr/bin/php -q
<?php
set_time_limit(0);
require(’phpagi/phpagi.php’);
$agi = new AGI();
$agi->answer();
$cid = $argv[1]; // ” $argv[1]” contain the asterisk variable value..here the value is 994000XXX $agi->verbose($cid); //This will print “9947000XXX″
?>
