Php 从asterisk agi执行ajax调用
我有一个Web服务,它接受电话号码和用户输入的号码。我想通过ajax调用执行这个webservice,在这个调用中我可以传递详细信息,ajax调用的结果将被回放给用户 但我不知道如何通过asterisk执行ajax调用。也许我们需要“AGI”,我试过了,但失败了 Extension.confPhp 从asterisk agi执行ajax调用,php,jquery,ajax,asterisk,agi,Php,Jquery,Ajax,Asterisk,Agi,我有一个Web服务,它接受电话号码和用户输入的号码。我想通过ajax调用执行这个webservice,在这个调用中我可以传递详细信息,ajax调用的结果将被回放给用户 但我不知道如何通过asterisk执行ajax调用。也许我们需要“AGI”,我试过了,但失败了 Extension.conf exten => s,1,Answer() exten => s,n,agi(googletts.agi,"Welcome to System. Please enter your number
exten => s,1,Answer()
exten => s,n,agi(googletts.agi,"Welcome to System. Please enter your number.",en)
exten => s,n,agi(a.php)
exten => s,n,WaitExten()
我试图用php实现这一点,但即使是我的php脚本也无法执行
a、 php
在浏览器中打开PHP文件。你有错误吗?“引号无效,会给您带来错误。谢谢,如果您在这两行中谈论$stdin=fopen”php://stdin","r",$stdlog=fopen'my_agi.log','w';然后修复了这两行代码,但仍然无法正常工作。并且浏览器和apache日志文件中没有php错误。
#!/usr/bin/php -q
<?
ob_implicit_flush(false);
set_time_limit(6);
$stdin = fopen(‘php://stdin’, ‘r’);
$stdlog = fopen(‘my_agi.log’, ‘w’);
SayDigits(6)
$debug = true;
/* Read input from Asterisk and output via $astOutput */
function astRead()
{
global $stdin, $debug, $stdlog;
$astOutput = str_replace("n", "", fgets($stdin, 4096));
if ($debug) fputs($stdlog, "read: $inputn");
return $astOutput ;
}
/* Write AGI command to Asterisk */
function astWrite($agiCommand)
{
global $debug, $stdlog;
if ($debug) fputs($stdlog, "write: $agiCommandn");
echo $agiCommand."n";
}
/* Handling execution input from Asterisk */
$agivar = array();
while (!feof($stdin))
{
$temp = fgets($stdin);
$temp = str_replace("n","",$temp);
$s = explode(":",$temp);
$agivar[$s[0]] = trim($s[1]);
if ($temp == "")
{
break;
}
}
/* Operational Code starts here */
/* Playback the demo-congrats.gsm file from the
* directory /var/lib/asterisk/sounds/
*/
astWrite("STREAM FILE demo-congrats #");
astRead();
/* Say the number 123456 */
astWrite("SAY NUMBER 123456 #");
astRead();
/* Finalization of AGI script and clean-ups */
fclose ($stdin);
fclose ($stdlog);
exit(0);
?>