我已经为Chrome设置了一个基于Asterisk AMI的click2call扩展来进行测试,但是当我给它发送一个数字时,它拒绝做任何事情。
如果我把http://10.8.0.2/amiscript.php?phone=5555555555&exten=910直接插入我的浏览器,我就会马上得到Please enter a number to dial.。它似乎没有正确地解释这个数字。
扩展链接:http://bitree.ru/click2call4chrome_en.html
显然,我使用的是PHP脚本示例。基于它返回给我一个错误,我假设我的web服务器端一切正常。脚本如下:
<? 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.
<?}?>有什么建议吗?
发布于 2016-08-20 06:29:35
首先,在php中有超过1个AMI协议(Full)的实现。
例如phpagi/phpami。
它已经很稳定了,而且工作正常。
我也可以建议你输出你得到的变量。
最简单的方法是在php代码的开头添加,如下所示
print_r($_REQUEST);https://stackoverflow.com/questions/39047817
复制相似问题