无法让Asterisk AMI click2call正常工作

时间:2016-08-19 21:19:18

标签: php apache google-chrome asterisk freepbx

我已经设置了一个基于Asterisk AMI的click2call扩展程序供Chrome测试,但是当我发送一个号码时它拒绝做任何事情。

如果我将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.
<?}?>

有什么建议吗?

1 个答案:

答案 0 :(得分:0)

首先,在php中有超过1个AMI协议(完整版)的实现。

例如phpagi / phpami。

它已经稳定并且正常工作。

我还建议你输出你得到的变量。

最简单的方法是在你的php代码的开头添加类似

的东西
print_r($_REQUEST);