HTTP POST

Version 1
    This document was generated from CDN thread

    Created by: JAMES DEPHILLIP II on 20-10-2010 06:36:10 PM
    Is there a way to perform a HTTP POST message to web server when a certain number is dialed?

    Subject: RE: HTTP POST
    Replied by: Yaw-Ming Chen on 20-10-2010 07:09:00 PM
    I think so but I never try it before.
     
    Thanks !

    Subject: RE: HTTP POST
    Replied by: JAMES DEPHILLIP II on 21-10-2010 06:01:36 PM
    I am trying to use this code to execute a command on an IP phone.  I don't know what I am missing or doing wrong.  Can anyone help?
     
    set auth "Basic dGhvbmdsZTpWb2ljZU4zdHdvcmshIQ=="
    set header1 [list Authorization $auth]
    ::httpios::geturl "http://10.10.40.16/CGI/Execute" -query "XML=%3CCiscoIPPhoneExecute%3E%3CExecuteItem%20Priority%3D0%20URL%3DPlay%3Achime.raw%2F%3E%3C%2FCiscoIPPhoneExecute%3E" -headers $header1 -command getEndCallResponse -timeout
    }
     
    proc getEndCallResponse {token} {
     
    global stParam
     
    puts "callback Status=[::httpios::status $token],"
    if {[string compare [::httpios::status $token] ok]} {
    set resp [::httpios::data $token]
    puts "Response:  $resp"
    }
    }

    Subject: RE: HTTP POST
    Replied by: Yaw-Ming Chen on 21-10-2010 06:11:31 PM
    Is this the complete codes ? If it is it's not going to work.There is no state machine.
    It may be easier to help if you can tell more detail what you are trying to do.
    "To execute a command on an IP phone" doesn't sound like a  normal Tcl IVR API task.
    There are other APIs like AXL, UCXSI interface with IP phone more.
    Tcl IVR is more in the function area of IVR and call control.
     
    Thanks !
     
     
     

    Subject: RE: HTTP POST
    Replied by: JAMES DEPHILLIP II on 21-10-2010 07:45:28 PM
    I have the FSM to initiate the code and do not see an error.  I am trying to perform a http push to an IP phone to Execute XML code.  When a call passes through the gateway I want to execute a CiscoIPPhoneStatusFile.
     
    proc init { } {
    leg setupack leg_incoming
    leg proceeding leg_incoming
    leg connect leg_incoming
    }
     
    proc act_Setup { } {
    global params
    global pattern
    global auth
    global header
    init
    set auth "Basic dGhvbmdsZTpWb2ljZU4zdHdvcmshIQ=="
    set header1 [list Authorization $auth]
    ::httpios::geturl "http://10.10.40.16/CGI/Execute" -query "XML=%3CCiscoIPPhoneExecute%3E%3CExecuteItem%20Priority%3D0%20URL%3DPlay%3Achime.raw%2F%3E%3C%2FCiscoIPPhoneExecute%3E" -headers $header1 -command getEndCallResponse -timeout
    }
     
    proc getEndCallResponse {token} {
     
    global stParam
     
    puts "callback Status=[::httpios::status $token],"
    if {[string compare [::httpios::status $token] ok]} {
    set resp [::httpios::data $token]
    puts "Response:  $resp"
    }
    }
     
    proc act_CallSetupDone { } { 
        global beep 
     
        set status [infotag get evt_status] 
     
        puts "Entering act_CallSetupDone"
        if { $status != "ls_000"} { 
            puts "Call [infotag get con_all] got event $status while placing an outgoing call" 
            call close 
        } 
    }
     
    proc act_Cleanup { } {
    call close 

     
    #---------------------------------- 
    #   State Machine 
    #---------------------------------- 
     set TopFSM(any_state,ev_disconnected) "act_Cleanup,same_state" 
     set TopFSM(CALL_INIT,ev_setup_indication) "act_Setup PLACECALL"
     set TopFSM(PLACECALL,ev_setup_done)  "act_CallSetupDone,CALLACTIVE" 
     set TopFSM(CALLACTIVE,ev_disconnected)   "act_Cleanup,CALLDISCONNECTED" 
     set TopFSM(CALLDISCONNECTED,ev_disconnect_done) "act_Cleanup,same_state" 
     
     fsm define TopFSM CALL_INIT

    Subject: RE: HTTP POST
    Replied by: Yaw-Ming Chen on 21-10-2010 09:22:36 PM
    What I can tell from you script is that there is no "leg setup" so you won't get "ev_setup_done" event.
     
    thanks !

    Subject: RE: HTTP POST
    Replied by: JAMES DEPHILLIP II on 22-10-2010 01:15:37 AM
    Yes I understand that I basically was just starting this script from one of my other scripts and have not got to that point as I am trying to get the httpios command working.  I see the router push out http packets to the IP Phone but don't know why it is not functioning.  I dont know if I need to perform a digest authentication and not a base 64 encoding.  Which I do not know if I can do that or not...

    Subject: RE: HTTP POST
    Replied by: Yaw-Ming Chen on 22-10-2010 01:38:11 AM
    Like I said before, Tcl IVR API malily is for call control and IVR. It provides limited function to interfcae with web server.
    To work with IP phone I have never heard anyone doing that. Maybe you can use AXL to verify whatever you like to do before try it in Tcl.
     
    Thanks,
     
    Yawming

    Subject: RE: HTTP POST
    Replied by: JAMES DEPHILLIP II on 22-10-2010 02:32:09 PM
    Yea I understand that but I determined what is happening here.  It is nor pushing the headers that I define in a list.  The http::geturl command says it is supported in the TCL/IVR guide and does not say that -header is an unsupported option.  If I push an invalid list to the -header command I also get this output.
     

    *Oct 22 14:30:14.902: TCL script failure 
    Result:
        header list not right 
    *Oct 22 14:30:14.902:  TCL script failure errorInfo:
       header list not right 
        while executing




    However, when the list is built correctly I do not get this error.