我最近需要为一个使用cakePHP构建的应用程序构建一个基于asterisk的IVR。
我想使用cakes的(胖)模型,这样我就不必重写业务逻辑。
我想创建一个从星号拨号方案调用的cakePHP外壳。
这是我所做的。
已将phpagi下载到供应商/phpagi。
修改的phpagi.php来自
function AGI($config=NULL, $optconfig=array())至:
function AGI($config=NULL, $optconfig=array(), $stdin, $stdout)所以我可以设置stdin和stdout。在167行附近,我更改了
$this->in = defined('STDIN') ? STDIN : fopen('php://stdin', 'r');
$this->out = defined('STDOUT') ? STDOUT : fopen('php://stdout', 'w');至
$this->in = $stdin;
$this->out = $stdout;在我的vendors/shells外壳中,我添加了
App::import('Vendor', 'AGI', array('phpagi/phpagi.php'));我还添加了
var $agi;
//redirect output through agi conlog
function err($message,$newlines = 1){
$this->agi->conlog($message);
}
function out($message, $newlines =1){
$this->agi->conlog($message);
}
//disable default message
function startup(){
}应用程序代码在
function main(){
$this->agi = new AGI(NULL, array(), $this->Dispatch->stdin,$this->Dispatch->stdout);
$this->agi->answer();
//do stuff here
}要在拨号方案中运行它,您需要做的就是
exten => s,n,AGI(${full/path/to/cake.php},${shellname},-app,${var/www/html/{appname}/app},-console,var/www/html/{appname}/cake/console/)请确保修复蛋糕目录上的权限。
我想知道有没有其他方法可以做到这一点?
发布于 2012-03-08 21:03:26
Here is a class会帮你完成所有的工作。它由最流行的Asterisk图形用户界面FreePBX维护,并在整个FreePBX中广泛使用。
https://stackoverflow.com/questions/9606636
复制相似问题