PureBasic
PureBasic
Example: Http.GetLastJsonData method
Demonstrates theGetLastJsonData method.
Chilkat PureBasic Downloads
IncludeFile "CkHttpResponse.pb"
IncludeFile "CkHttp.pb"
IncludeFile "CkJsonObject.pb"
Procedure ChilkatExample()
success.i = 0
http.i = CkHttp::ckCreate()
If http.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
resp.i = CkHttpResponse::ckCreate()
If resp.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
; Only allow TLS 1.2 or better.
CkHttp::setCkSslProtocol(http, "TLS 1.2 or higher")
success = CkHttp::ckHttpNoBody(http,"GET","https://google.com/",resp)
If success = 0
Debug CkHttp::ckLastErrorText(http)
CkHttp::ckDispose(http)
CkHttpResponse::ckDispose(resp)
ProcedureReturn
EndIf
json.i = CkJsonObject::ckCreate()
If json.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
CkJsonObject::setCkEmitCompact(json, 0)
CkHttp::ckGetLastJsonData(http,json)
Debug CkJsonObject::ckEmit(json)
; Output as of Chilkat v11.1.0
; Additional information may be added as requested or needed in future versions of Chilkat.
; {
; "tls": {
; "params": {
; "sniHostname": "www.google.com",
; "allowConnectionOnlyIfServerChooses": "TLS 1.2 or higher"
; },
; "negotiatedTlsVersion": "TLS 1.3"
; }
; }
CkHttp::ckDispose(http)
CkHttpResponse::ckDispose(resp)
CkJsonObject::ckDispose(json)
ProcedureReturn
EndProcedure