我的拨号方案就像这样
[dial-plan]
exten => s,1,Answer()
exten => s,n,Noop(exten = ${EXTEN}
exten => s,n,Macro(dumpvars)
exten => s,n,Macro(record-enable)
exten => s,n,AGI(success.php)
exten => i,1,Noop(REASON = ${REASON})
exten => i,n,Macro(dumpvars)
exten => i,n,AGI(faile.php)
exten => failed,1,Noop(REASON = ${REASON})
exten => failed,n,Macro(dumpvars)
exten => failed,n,AGI(faile.php)
我想从faile.php调用的地方捕获,可以从failed
或i
调用。我该如何检查
我需要这样做是faile.php
if($some_var == 1){
//Invalid
}
elsif($some_var == 2){
//Failed
}
答案 0 :(得分:1)
将使用一些标准参数调用agi,包括被叫扩展(在您的情况下,将是i
或failed
)。确保您正在解析传递给脚本的参数(通过stdin)!
答案 1 :(得分:0)
在脚本中使用phpagi.php,它为AGI提供所有必需的解析。
上的示例答案 2 :(得分:0)
如果我正确理解了您的问题,您需要将变量传递给PHP AGI脚本。 这是如何做到的:
exten => i,n,AGI(faile.php,invalid)
exten => failed,n,AGI(faile.php,failed)
然后,您的PHP AGI脚本应如下所示:
#!/usr/bin/php -q
<?php
set_time_limit(30);
//load PHP AGI
require('phpagi/phpagi.php');
error_reporting(E_ALL);
$agi = new AGI();
$status = $argv[1];
if($status == "invalid")
{
// invalid
} else
{
// failed
}
?>
答案 3 :(得分:0)
以下是我与php-agi.php
实现相同的方法<?php
require_once "phpagi.php";
require_once "phpagi-asmanager.php";
$astman = new AGI();
$astman->set_variable('CallState','failed');
?>
<?php
require_once "phpagi.php";
require_once "phpagi-asmanager.php";
$astman = new AGI();
$astman->set_variable('CallState','success');
?>
<?php
require_once "phpagi.php";
require_once "phpagi-asmanager.php";
$astman = new AGI();
$call_state = agi_get_var('CallState');
if($call_state == "success"){
//call was success
}
elseif($call_state == "failed"){
//call was failed
}
?>
答案 4 :(得分:0)
在Dialplan中
exten => _*999*.,1,Answer()
exten => _*999*.,n,Set(var1=1)
exten => _*999*.,n,AGI(test.php,${var1})
在php
<?php
require('phpagi.php');
$agi = new AGI();
$agi->say_digit($argv[1]);
$agi->hangup();
?>