php - 从 php 连接到 Asterisk

标签 php linux asterisk

如何连接到 Asterisk 服务器或如何执行 asterisk 命令? 我一直在尝试 execshell_exec 和 e.t.c 无法正常工作,但如果我尝试 exec('ls') 效果很好。我已经安装了 chan_dongle所以我需要使用 "asterisk -rx 'dongle sms dongle0 $phonenumber $textmessage'",但它不工作,从控制台它工作

最佳答案

private function my_exec($cmd, $input = '')
{
    $proc = proc_open($cmd, array(0 => array('pipe', 'r'), 1 => array('pipe', 'w'), 2 => array('pipe', 'w')), $pipes);
    fwrite($pipes[0], $input);
    fclose($pipes[0]);
    $stdout = stream_get_contents($pipes[1]);
    fclose($pipes[1]);
    $stderr = stream_get_contents($pipes[2]);
    fclose($pipes[2]);
    $rtn = proc_close($proc);
    return array('stdout' => $stdout,
        'stderr' => $stderr,
        'return' => $rtn
    );
}

检查这个函数,它帮了我一次。

关于php - 从 php 连接到 Asterisk,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23171815/

相关文章:

c++ - 我怎样才能得到执行我的程序的人的用户名?

linux - 在 CentOS 5 中使用 Asterisk 进行 IVR 集成

ubuntu - 调用多部电话 - Asterisk

linux - 在 shell 脚本中复制一个变量 (Linux)

php - 在 ubuntu 14.04 上使用 FastCGI php5-fpm 的 Apache 2.4

php - 有什么方法可以用 Laravel 检测数据库表是否存在

php - MySQL 选择两个日期之间的所有日期

linux - 权限被拒绝尝试使用 openssl、sudo 从网站下载证书

java - Asterisk - 如何为音频文件添加书签

php - 从 html 页面提交时,值未插入数据库