[英]Trouble getting Asterisk AMI click2call working
I've setup an Asterisk AMI-based click2call extension for Chrome to test out, but it refuses to do anything when I send it a number. 我已经为Chrome设置了一个基于Asterisk AMI的click2call扩展程序进行测试,但是当我发送号码时它拒绝执行任何操作。
If I plug http://10.8.0.2/amiscript.php?phone=5555555555&exten=910
right into my browser, I just get Please enter a number to dial.
如果我将
http://10.8.0.2/amiscript.php?phone=5555555555&exten=910
直接插入浏览器,我会得到Please enter a number to dial.
right back. 马上回来。 It doesn't seem to be interpreting the number correctly.
似乎无法正确解释数字。
Link to the extension: http://bitree.ru/click2call4chrome_en.html 链接到扩展程序: http : //bitree.ru/click2call4chrome_en.html
I'm using the PHP script example, obviously. 显然,我使用的是PHP脚本示例。 And based on it giving me an error back, I assume everything is good on my web server end.
基于此,我得到了一个错误,我认为我的Web服务器端一切都很好。 Here's the script:
这是脚本:
<? if (!empty( $_REQUEST['phone']) && !empty( $_REQUEST['exten'] ) )
{
$num = $_REQUEST['phone'];
$ext = $_REQUEST['exten'];
$num = preg_replace( "/^\+7/", "8", $num );
$num = preg_replace( "/\D/", "", $num );
if ( ! empty( $num ) )
{
echo "Dialing $num\r\n";
$timeout = 10;
$asterisk_ip = "127.0.0.1";
$socket = fsockopen($asterisk_ip,"5038", $errno, $errstr, $timeout);
fputs($socket, "Action: Login\r\n");
fputs($socket, "UserName: bitree\r\n");
fputs($socket, "Secret: bitree_secret\r\n\r\n");
$wrets=fgets($socket,128);
echo $wrets;
fputs($socket, "Action: Originate\r\n" );
fputs($socket, "Channel: Local/$ext@from-internal\r\n" );
fputs($socket, "Exten: $num\r\n" );
fputs($socket, "Context: from-internal\r\n" );
fputs($socket, "Priority: 1\r\n" );
fputs($socket, "Async: yes\r\n" );
fputs($socket, "WaitTime: 15\r\n" );
fputs($socket, "Callerid: $num\r\n\r\n" );
$wrets=fgets($socket,128);
echo $wrets;
}
else
{
echo "Unable to determine number from (" . $_REQUEST['phone'] . ")\r\n";
}
}
else
{?>Please enter a number to dial.
<?}?>
Any suggestions? 有什么建议么?
First of all, there are more then 1 realisation of AMI protocol(full) in php. 首先,在php中有超过1的AMI协议(完整)实现。
For example phpagi/phpami. 例如phpagi / phpami。
It already stable and work ok. 它已经稳定并且可以正常工作。
Also i can recommend you do output of variables you get. 我也可以建议您进行变量输出。
Simplest method is add at start of your php code something like 最简单的方法是在您的php代码开始处添加类似
print_r($_REQUEST);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.