Last active
August 29, 2015 14:02
-
-
Save lyonsun/cda807ad2dd949610dc6 to your computer and use it in GitHub Desktop.
a basic vbs script to accomplish HTTP POST
This file contains hidden or 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
| 'URL to open.... | |
| sUrl = "http://example.com" | |
| 'POST Request to send. | |
| sRequest = "post=true" | |
| sDestFolder = "C:/" | |
| sImageFile = "example" & "_" & Year(Date) & "_" & Month(Date) & "_" & Day(Date) & ".log" | |
| WScript.Echo "Done..." | |
| 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 | |
| HTTPBody = oHTTP.responseBody | |
| strFile = sDestFolder & sImageFile | |
| Const ForAppending = 8 | |
| set objFSO = CreateObject("Scripting.FileSystemObject") | |
| set objFile = objFSO.OpenTextFile(strFile, ForAppending, True) | |
| objFile.WriteLine("Time Stamp: " & Now) | |
| objFile.WriteLine(HTTPPost) | |
| objFile.Close | |
| End Function |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment