duancan1732 2012-07-12 09:01
浏览 88
已采纳

从拨号方案到AGI脚本的星号服务器传递变量

My Dialplan is like this

[dial-plan]
exten => s,1,Answer()
exten => s,n,Noop(exten = ${EXTEN}
exten => s,n,Macro(dumpvars)
exten => s,n,Macro(record-enable)
exten => s,n,AGI(success.php)
exten => i,1,Noop(REASON = ${REASON})
exten => i,n,Macro(dumpvars)
exten => i,n,AGI(faile.php)
exten => failed,1,Noop(REASON = ${REASON})
exten => failed,n,Macro(dumpvars)
exten => failed,n,AGI(faile.php)

I want to catch from where faile.php called , It may be called from failed or from i . How can I check this

I need to make like this is faile.php

if($some_var == 1){
     //Invalid
}
elsif($some_var == 2){
    //Failed
}
  • 写回答

5条回答 默认 最新

  • dongtang1909 2014-06-06 08:43
    关注

    Here is how I implemented same with php-agi.php

    failed.php (will execute if call failed)

    <?php
        require_once "phpagi.php";
        require_once "phpagi-asmanager.php";
    
        $astman = new AGI();
        $astman->set_variable('CallState','failed');
    
    ?>
    

    success.php (will execute if call success)

    <?php
        require_once "phpagi.php";
        require_once "phpagi-asmanager.php";
    
        $astman = new AGI();
        $astman->set_variable('CallState','success');
    
    ?>
    

    hangup.php (will execute on end of the call, if call failed or success)

    <?php
        require_once "phpagi.php";
        require_once "phpagi-asmanager.php";
    
        $astman = new AGI();
        $call_state = agi_get_var('CallState');
        if($call_state == "success"){
            //call was success
        }
        elseif($call_state == "failed"){
            //call was failed
        }
    ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?

悬赏问题

  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示