Created
March 21, 2016 18:03
-
-
Save cabloo/387f1d6d8fe81752574d to your computer and use it in GitHub Desktop.
VBScript mini CURL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Set colNamedArguments = WScript.Arguments.Named | |
url = colNamedArguments.Item("url") | |
data = "" | |
ContentType = "application/x-www-form-urlencoded" | |
If colNamedArguments.Exists("method") Then | |
method = colNamedArguments.Item("method") | |
Else | |
method = "GET" | |
End If | |
If colNamedArguments.Exists("json") Then | |
ContentType = "application/json" | |
End If | |
If colNamedArguments.Exists("dataFile") Then | |
Set objFS = CreateObject("Scripting.FileSystemObject") | |
dataFile = colNamedArguments.Item("dataFile") | |
Set dataFileHandle = objFS.OpenTextFile(dataFile) | |
Do Until dataFileHandle.AtEndOfStream | |
data = data & dataFileHandle.ReadLine | |
Loop | |
dataFileHandle.Close | |
End If | |
dim xmlhttp: Set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP") | |
xmlhttp.Open method, url, False | |
xmlhttp.setRequestHeader "Content-Type", ContentType | |
xmlhttp.send data | |
WScript.Echo xmlhttp.responseText | |
Set xmlhttp = Nothing |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
example usage: