麻烦获得Asterisk AMI click2call工作



我已经为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 $numrn";
                $timeout = 10;
                $asterisk_ip = "127.0.0.1";
                $socket = fsockopen($asterisk_ip,"5038", $errno, $errstr, $timeout);
                fputs($socket, "Action: Loginrn");
                fputs($socket, "UserName: bitreern");
                fputs($socket, "Secret: bitree_secretrnrn");
                $wrets=fgets($socket,128);
                echo $wrets;
                fputs($socket, "Action: Originatern" );
                fputs($socket, "Channel: Local/$ext@from-internalrn" );
                fputs($socket, "Exten: $numrn" );
                fputs($socket, "Context: from-internalrn" );
                fputs($socket, "Priority: 1rn" );
                fputs($socket, "Async: yesrn" );
                fputs($socket, "WaitTime: 15rn" );
                fputs($socket, "Callerid: $numrnrn" );
                $wrets=fgets($socket,128);
                echo $wrets;
        }
        else
        {
                echo "Unable to determine number from (" . $_REQUEST['phone'] . ")rn";
        }
}
else
{?>Please enter a number to dial.
<?}?>

有什么建议吗?

首先,php中有超过1种AMI协议的实现(全部)

例如phpagi/phpami。

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

我也可以建议你输出你得到的变量。

最简单的方法是在php代码的开头添加一些东西,比如

print_r($_REQUEST);

最新更新