DP: CallBack 應用實例

    版本為 05:37, 27 Dec 2024

    到這個版本。

    返回到 版本存檔.

    查閱目前版本

    客戶需求說明

    •  新增一個 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。

    主要檔案

    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)

    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(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
    
    Powered by MindTouch Core