客戶需求說明
- 新增一個 CallBack.php,並且可以使其他應用程式透過 URL 觸發撥號,例如 http://xxx.xxx.xxx/callback.php?to_number=1234567 。
- CallBack.php 以 AMI 方式與 Asterisk 連接並建立外撥通話。
- 當 1234567 用戶接起電話後,會聽到一段語音,如果用戶按 1,電話會轉接到一個指定的號碼,例如是 666666
- 不管任何情形,通話結束後,系統必須觸發一段 URL,例如 http://yyy.yyy.yyy/finished.php?to_number=1234567。
主要檔案
manager.conf:
[callback]
secret=qsxesz8825252
deny=0.0.0.0/0.0.0.0
permit=127.0.0.1/255.255.255.0
read=originate
write=originate
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:
[internal]
include => demo
include => outgoing
[outgoing]
exten => _XXXXX.,1,Noop(Dialing out thru Skype)
exten => _XXXXX.,n,Set(DIAL_TIMEOUT=40)
exten => _XXXXX.,n,Dial(SIP/skype/${EXTEN},${DIAL_TIMEOUT})
exten => _XXXXX.,n,Congestion(5)
exten => h,1,Hangup
exten => i,1,Hangup
exten => t,1,Hangup
[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()
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/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,Noop(Caller don't make any decisions)
exten => t,n,Goto(cb${AGENT},restart)
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,Set(foo=${CURL(http://finishedcall.cheapjailcalls.com/finished.php?to_number=${Call_From})})
exten => h,n,Noop(The HTTP Response Codes: ${foo})
exten => h,n,Hangup