客戶需求說明
- 新增一個 CallBack.php,並且可以使其他應用程式透過 URL 觸發撥號,例如 http://xxx.xxx.xxx/callback.php?to_number=1234567 。
- 當 1234567 用戶接起電話後,會聽到一段語音,如果用戶按 1,電話會轉接到一個指定的號碼,例如是 666666
- 不管任何情形,通話結束後,系統必須觸發一段 URL,例如 http://yyy.yyy.yyy/finished.php?to_number=1234567。
主要檔案
CallBack.php:
reference to undefined name 'syntax' Exception of type 'MindTouch.Deki.Script.Runtime.DekiScriptUndefinedNameException' was thrown. (click for details)Callstack:
at User:alang/Private_Zone/Asterisk_開發筆記/DP:_CallBack_應用實例
MindTouch.Deki.Script.Runtime.DekiScriptUndefinedNameException: reference to undefined name 'syntax' Exception of type 'MindTouch.Deki.Script.Runtime.DekiScriptUndefinedNameException' was thrown.
at MindTouch.Deki.Script.Compiler.DekiScriptExpressionEvaluation.Visit (MindTouch.Deki.Script.Expr.DekiScriptVar expr, DekiScriptExpressionEvaluationState state) [0x00000] in <filename unknown>:0
at MindTouch.Deki.Script.Expr.DekiScriptVar.VisitWith[DekiScriptExpressionEvaluationState,Range] (IDekiScriptExpressionVisitor`2 visitor, DekiScriptExpressionEvaluationState state) [0x00000] in <filename unknown>:0
at MindTouch.Deki.Script.Compiler.DekiScriptExpressionEvaluation.Evaluate (MindTouch.Deki.Script.Expr.DekiScriptAccess expr, DekiScriptExpressionEvaluationState state, Boolean evaluateProperties) [0x00000] in <filename unknown>:0
at MindTouch.Deki.Script.Compiler.DekiScriptExpressionEvaluation.Visit (MindTouch.Deki.Script.Expr.DekiScriptAccess expr, DekiScriptExpressionEvaluationState state) [0x00000] in <filename unknown>:0
at MindTouch.Deki.Script.Expr.DekiScriptAccess.VisitWith[DekiScriptExpressionEvaluationState,Range] (IDekiScriptExpressionVisitor`2 visitor, DekiScriptExpressionEvaluationState state) [0x00000] in <filename unknown>:0
at MindTouch.Deki.Script.Compiler.DekiScriptExpressionEvaluation.Visit (MindTouch.Deki.Script.Expr.DekiScriptCall expr, DekiScriptExpressionEvaluationState state) [0x00000] in <filename unknown>:0
at MindTouch.Deki.Script.Expr.DekiScriptCall.VisitWith[DekiScriptExpressionEvaluationState,Range] (IDekiScriptExpressionVisitor`2 visitor, DekiScriptExpressionEvaluationState state) [0x00000] in <filename unknown>:0
at MindTouch.Deki.Script.Compiler.DekiScriptExpressionEvaluation.Visit (MindTouch.Deki.Script.Expr.DekiScriptSequence expr, DekiScriptExpressionEvaluationState state) [0x00000] in <filename unknown>:0
at MindTouch.Deki.Script.Expr.DekiScriptSequence.VisitWith[DekiScriptExpressionEvaluationState,Range] (IDekiScriptExpressionVisitor`2 visitor, DekiScriptExpressionEvaluationState state) [0x00000] in <filename unknown>:0
at MindTouch.Deki.Script.Compiler.DekiScriptExpressionEvaluation.Visit (MindTouch.Deki.Script.Expr.DekiScriptReturnScope expr, DekiScriptExpressionEvaluationState state) [0x00000] in <filename unknown>:0
Dialplan:
[php_callback]
exten => _cbX.,1,Noop(This call is made from CallBack)
exten => _cbX.,n,Set(Call_From=${CALLERID(num)})
exten => _cbX.,n,Answer
exten => _cbX.,n(restart),Set(TIMEOUT(digit)=5) ; Set Digit Timeout to 5 seconds
exten => _cbX.,n,Set(TIMEOUT(response)=10) ; Set Response Timeout to 10 seconds
exten => _cbX.,n,Set(AGENT=${EXTEN:2})
exten => _cbX.,n,BackGround(custom/cjc_no_funds_call)
exten => _cbX.,n,WaitExten(5)
exten => _cbX.,n,Hangup
exten => 1,1,Noop(Caller pressed 1 so the call will bridge with the number ${AGENT})
exten => 1,n,Set(DIAL_TIMEOUT=40)
;exten => 1,n,Dial(SIP/${AGENT},${DIAL_TIMEOUT})
exten => 1,n,Dial(SIP/skype/${AGENT},${DIAL_TIMEOUT})
exten => 1,n,Hangup
exten => i,1,Noop(Caller pressed invalid number)
exten => i,n,Goto(cb${AGENT},restart)
exten => t,1,Hangup
exten => h,1,Noop(The Call has been terminated.)
exten => h,n,Noop(Hitting the link http://finishedcall.cheapjailcalls.com/finished.php?to_number=${Call_From})
exten => h,n,Hangup