【问题标题】:Asterisk AGI and Mysql string variabileAsterisk AGI 和 Mysql 字符串变量
【发布时间】:2018-11-01 01:14:06
【问题描述】:

我不能解决一个问题,脚本的目的是识别上下文编号。

下面是星号拨号计划 extensions.conf

exten => 1234,1,Answer()
same => n,Set(NUM2CALL=Hello, your number is eight)
same => n,NOOP(${NUM2CALL})
same => n,AGI(test.php,${NUM2CALL})

运行test.php的文件

#!/usr/bin/php -q
<?php
require '/var/lib/asterisk/agi-bin/phpagi/phpagi.php';
$agi = new AGI();

//DB connect
$mysqli = new mysqli('127.0.0.1', 'root', 'testdatabase', 'asterisk');

if (mysqli_connect_errno())
{
    printf("Connect failed: %s\n", mysqli_connect_error());

    exit();
}
//End

$query  = "SELECT text, number FROM recognation_2";
$result = $mysqli->query($query);

while ($row = $result->fetch_object())
{
    if(strpos($argv[1], $row->text) !== FALSE)
    {
        echo $row->number;
    }
}


?>

【问题讨论】:

  • AGI Tx >> 510 无效或未知命令 [Oct 31 11:35:49] 错误 [20679]: utils.c:1164 ast_carefulwrite: write() 返回错误: Broken pipe -- AGI Script test.php 完成,返回 0
  • 你不需要 agi 类。删除它们并尝试在“php myfile.php”之类的控制台上进行调试,它给出了一些解决问题的提示。

标签: mysql asterisk agi


【解决方案1】:

你在开玩笑吗?为什么不问 db 一行?

$query  = "SELECT text, number FROM recognation_2 where text = "+mysqli_real_escape_string($mysqli,$argv[1]);

这个任务的最佳选择就是使用 func_odbc,不需要任何 php 或 agi。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多