我最近需要爲使用cakePHP構建的應用程序構建基於星號的IVR。PHPAGI使用CakePHP SHELL
我想使用蛋糕的(胖)模型,所以我不必重新編寫業務邏輯。
我想創建一個cakephp shell,它將從星號撥號方案中調用。
這就是我所做的。
將phpagi下載到供應商/ phpagi。
改性phpagi.php從
function AGI($config=NULL, $optconfig=array())
到:
function AGI($config=NULL, $optconfig=array(), $stdin, $stdout)
以便設定stdin和stdout。圍繞線167我在vendors/shells
改變
$this->in = defined('STDIN') ? STDIN : fopen('php://stdin', 'r');
$this->out = defined('STDOUT') ? STDOUT : fopen('php://stdout', 'w');
要
$this->in = $stdin;
$this->out = $stdout;
在我的殼我加
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/)
務必將蛋糕上的顯示目錄權限。
我想知道如果有人有任何其他方式來做到這一點?
我對stdin和stdout感到困惑。你爲什麼添加這個? – 2012-03-08 02:13:40
它不工作嗎?我認爲調度抓住了標準輸入 – josephtikva1 2012-03-08 04:07:53
我相信你可以使用參數。 – 2012-03-08 06:01:15