从php连接到Asterisk

时间:2014-04-19 15:21:43

标签: php linux asterisk

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

1 个答案:

答案 0 :(得分:1)

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
    );
}

检查这个功能,它帮了我一次。