简体   繁体   English

DTMF不被PHP Agi接受

[英]DTMF not accepted on PHP Agi

I am trying to grab the DTMF from user, if its equal to zero then transfer call to an extension else hangup. 我正在尝试从用户那里获取DTMF,如果它等于零,则将呼叫转移到分机上,否则挂断。 I have written the following, but it directly plays invalid entry and hangs up my call. 我已经写了以下内容,但是它直接播放无效的条目并挂断我的电话。 Would appreciate help over this matter. 希望能对此事有所帮助。

$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(); 
}
}

Have be like this 像这样

$dtmf = $whereto['result'];

if ($dtmf=="0")

Please read corefully phpagi docs and examples 请仔细阅读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
}

This is the code that has worked for me.. if I try anything instead of 'silence/1' or 'beep' then it gives me an error message, invalid entry! 这是对我有用的代码..如果我尝试任何操作而不是'silence / 1'或'beep',那么它会给我一个错误消息,输入无效!

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM