Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Perform an HTTP/1.1 POST in VBScript  (Read 41532 times)

0 Members and 1 Guest are viewing this topic.

bobsklarservices

    Topic Starter


    Beginner

  • Time is of the essence.
  • Thanked: 2
    • Certifications: List
    • Experience: Experienced
    • OS: Other
    Perform an HTTP/1.1 POST in VBScript
    « on: December 30, 2011, 03:31:31 AM »
    I have had the idea to make a "Chat Autofixer" for XSketch.com, and in order to do this, I basically flood the chat with a message consisting of [ ]. I want to make it distributable, for my XSketch friends, and source-viewable. I'd like to do this using VBScript. Unfortunately, the server running XSketch is using GWT with a POST to send messages, and I don't know how to execute a POST in VBS. I only need to post a string, and I know what URL to post to. Does anyone know the code required to perform such an action?

    PS> This will also help in my VB.NET application coming soon that will use POST.
    Work to be all you can be. You define your limits!

    Rob Pomeroy



      Prodigy

    • Systems Architect
    • Thanked: 124
      • Me
    • Experience: Expert
    • OS: Other
    Re: Perform an HTTP/1.1 POST in VBScript
    « Reply #1 on: December 31, 2011, 11:55:12 AM »
    Ugh.  I wouldn't use VBScript for this.  Any language that can use a cURL library is a better bet.  But if you're determined, you might find some inspiration here: http://www.motobit.com/tips/detpg_post-binary-data-url/
    Only able to visit the forums sporadically, sorry.

    Geek & Dummy - honest news, reviews and howtos

    BC_Programmer


      Mastermind
    • Typing is no substitute for thinking.
    • Thanked: 1140
      • Yes
      • Yes
      • BC-Programming.com
    • Certifications: List
    • Computer: Specs
    • Experience: Beginner
    • OS: Windows 11
    Re: Perform an HTTP/1.1 POST in VBScript
    « Reply #2 on: December 31, 2011, 11:43:31 PM »
    Code: [Select]
    'URL to open....
    sUrl = "http://www.example.com/page.php"
    'POST Request to send.
    sRequest = "varname=value&varname=value"

    HTTPPost sUrl, sRequest

    Function HTTPPost(sUrl, sRequest)
      set oHTTP = CreateObject("Microsoft.XMLHTTP")
      oHTTP.open "POST", sUrl,false
      oHTTP.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
      oHTTP.setRequestHeader "Content-Length", Len(sRequest)
      oHTTP.send sRequest
      HTTPPost = oHTTP.responseText
     End Function
    I was trying to dereference Null Pointers before it was cool.

    bobsklarservices

      Topic Starter


      Beginner

    • Time is of the essence.
    • Thanked: 2
      • Certifications: List
      • Experience: Experienced
      • OS: Other
      Re: Perform an HTTP/1.1 POST in VBScript
      « Reply #3 on: January 02, 2012, 07:28:23 PM »
      Thanks to everyone for your helpfulness. I am now able to do what I was desiring to do in the first place. I officially declare this topic solved!
      Work to be all you can be. You define your limits!