脚本如下
require_once(\"/var/lib/asterisk/agi-bin/phpagi-asmanager.php\");require_once(\"/var/lib/asterisk/agi-bin/phpagi.php\");
//使⽤Command必须先使⽤phpagi-asmanager的connect函数连接⾄后台$host = '127.0.0.1';$username = 'admin';$secret = '29666985';
define('MAX_TRY_TIMES',3); //定义重试次数
define('TIMEOUT',4000); //定义超时时间,单位毫秒
$agi = new AGI(); //调⽤phpagi脚本中的函数
$ami = new AGI_AsteriskManager();//调⽤phpagi-asmanager脚本中的函数$conn = $ami->connect($host,$username,$secret);if( $conn == false ){ //连接失败echo \"Connection failed.\\n\";die;}
$channel = $agi->get_variable(\"CDR(channel)\"); //获取通道值$channel = $channel[\"data\"];
$arrReturn = $ami->Command(\"core show channel $channel\");//在脚本中执⾏asterisk后台命令获取通道参数$lines=explode(\"\\n\$ary = array();
$ary['Channel'] = substr($lines[2],strpos($lines[2],\":\")+2); //客户通道$ary['Extension'] = substr($lines[8],strpos($lines[8],\":\")+2); //分机号
$ary['ExtenChannel'] = substr($lines[41],strpos($lines[41],\"=\")+1); //坐席通道$agi->set_variable(\"WKK\通道变量-分机号$agi->set_variable(\"ExtenChannel\坐席通道$ami->disconnect();
因篇幅问题不能全部显示,请点此查看更多更全内容