从php连接到Asterisk

从php连接到Asterisk,php,linux,asterisk,Php,Linux,Asterisk,如何连接到Asterisk服务器或如何执行Asterisk命令? 我一直在尝试exec,shell\u exec和e.t.c,但如果我尝试exec('ls'),它工作得很好。我已经安装了chan\u dongle,所以我需要使用“asterisk-rx'dongle sms dongle0$phonenumber$textmessage'”,但它不工作,从控制台它可以工作 private function my_exec($cmd, $input = '') { $proc = proc

如何连接到Asterisk服务器或如何执行Asterisk命令? 我一直在尝试
exec
shell\u exec
和e.t.c,但如果我尝试
exec('ls')
,它工作得很好。我已经安装了chan\u 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
    );
}
检查这个功能,它曾经帮助过我