Jump to content
Gold Sponsor: Data-Way IT-Consulting, Austria

  • LaunchHTTPRequestEx

    LaunchHTTPRequestEx

    VBScript   → Lua

     

    This function calls (launches) a given URL (http request) and returns True if the request returns without error.

    Please see the Introduction chapter for some usage instructions.

     

    '-------------------------------------------------------------------
    ' LaunchHTTPRequestEx
    ' 
    ' Launches given URL by using the Swyx Server build-in PBXScript.WebRequest
    '
    ' Parameter:
    '   sURL        complete url
    '
    ' return value:
    '   boolean     True  - request returned 200
    '               False - request returned anything else
    '--------------------------------------------------------------------
    Function LaunchHTTPRequestEx(sURL)
        PBXScript.OutputTrace "------> LaunchHTTPRequestEx ( sURL = '" & sURL & "' )"
    
        On Error Resume Next
    
        Dim bReturn
        bReturn = False
    
        Dim oWebRequest, respCode
    
        Set oWebRequest = PBXScript.WebRequest
        oWebRequest.HttpVerb = HttpVerbGet
        oWebRequest.URL      = sURL
        oWebRequest.AddHeader "Content-Type:application/text"
    
        Dim vBefore, vAfter, nDuration
    
        vBefore = Now
        respCode = oWebRequest.Execute
        vAfter = Now
    
        nDuration = DateDiff("s", vBefore, vAfter)
        PBXScript.OutputTrace "HTTP Request returned after " & nDuration & " seconds"
    
        PBXScript.OutputTrace "Response Code = " & respCode
        'PBXScript.OutputTrace "Response Body = " & oWebRequest.ResponseBody
    
        bReturn = (respCode = 200)
    
        LaunchHTTPRequestEx = bReturn
    
        PBXScript.OutputTrace "bReturn = " & bReturn
        PBXScript.OutputTrace "<------ LaunchHTTPRequestEx"
    End Function

     

    This function makes use of the Server Script API object PBXScript.WebRequest to perform the web reaquest and the function PBXScript.OutputTrace to write trace information into the SwyxServer trace file.

     

    The PBXScript.WebRequest object was introducued with SwyxWare 12.40.

     

    Another version of this function which makes use of the Windows "Msxml2.ServerXMLHTTP" object to perform the web request can be found in the LaunchHTTPRequest function.

     

     


    Tom Wellige
     Share


     Share




    User Feedback

    Recommended Comments

    There are no comments to display.



    Guest
    Add a comment...

    ×   Pasted as rich text.   Paste as plain text instead

      Only 75 emoji are allowed.

    ×   Your link has been automatically embedded.   Display as a link instead

    ×   Your previous content has been restored.   Clear editor

    ×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and have taken note of our Privacy Policy.
We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.