DTMF not accepted on PHP Agi



我试图从用户获取DTMF,如果它等于零,那么将呼叫转移到扩展否则挂断。我写了下面的代码,但是它直接播放无效条目并挂断我的电话。我希望你能帮我解决这件事。

$wheretorec = $agi->exec("AGI","googletts.agi,"To speak to an operator press zero.",en"); 
$whereto = $agi->get_data($wheretorec, 10000, 1);
$dtmf = $whereto['result'];
if (is_numeric($dtmf ['0'])) 
{
$agi->exec("AGI","googletts.agi,"Your call is now being transferred",en");
$agi->exec('transfer',"SIP/123@12.345.678.901:5080");   
$agi->hangup();
} 
else 
{
$agi->exec("AGI","googletts.agi,"Invalid entry. Please try again later.",en");
$agi->hangup(); 
}
}

必须这样

$dtmf = $whereto['result'];
if ($dtmf=="0")

请仔细阅读phpagi文档和示例

$dtmfTemp = $agi->get_data("File_name_you_want_to_play", 6000, 1);
$dtmf = $dtmfTemp['result'];
if($dtmf=="0"){
//Do your stuff
}
else{
//Do your other stuff
}

这是为我工作的代码。如果我尝试任何东西而不是'silence/1'或'beep',那么它会给我一个错误消息,无效的输入!

$press1 = $agi->get_data('silence/1',50000, 1);
$press1dtmf = $press1['result'];

相关内容

  • 没有找到相关文章

最新更新