(PureBasic) Example: Http.QuickGetStr method
Demonstrates the QuickGetStr method.
IncludeFile "CkHttp.pb"
Procedure ChilkatExample()
http.i = CkHttp::ckCreate()
If http.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
; Keep the response body if there's an error.
CkHttp::setCkKeepResponseBody(http, 1)
; Send the HTTP GET and return the content in a string.
str.s = CkHttp::ckQuickGetStr(http,"https://www.chilkatsoft.com/helloWorld.json")
If CkHttp::ckLastMethodSuccess(http) = 0
If CkHttp::ckLastStatus(http) = 0
; Communications error. We did not get a response.
Debug CkHttp::ckLastErrorText(http)
Else
Debug "Response status code: " + Str(CkHttp::ckLastStatus(http))
Debug "Response body error text:"
Debug CkHttp::ckLastResponseBody(http)
EndIf
CkHttp::ckDispose(http)
ProcedureReturn
EndIf
Debug str
Debug "Success"
CkHttp::ckDispose(http)
ProcedureReturn
EndProcedure
|