(VBScript) Example: Http.QuickGetStr method
Demonstrates the QuickGetStr method.
Dim fso, outFile
Set fso = CreateObject("Scripting.FileSystemObject")
'Create a Unicode (utf-16) output text file.
Set outFile = fso.CreateTextFile("output.txt", True, True)
set http = CreateObject("Chilkat.Http")
' Keep the response body if there's an error.
http.KeepResponseBody = 1
' Send the HTTP GET and return the content in a string.
str = http.QuickGetStr("https://www.chilkatsoft.com/helloWorld.json")
If (http.LastMethodSuccess = 0) Then
If (http.LastStatus = 0) Then
' Communications error. We did not get a response.
outFile.WriteLine(http.LastErrorText)
Else
outFile.WriteLine("Response status code: " & http.LastStatus)
outFile.WriteLine("Response body error text:")
outFile.WriteLine(http.LastResponseBody)
End If
WScript.Quit
End If
outFile.WriteLine(str)
outFile.WriteLine("Success")
outFile.Close
|