Sample code for 30+ languages & platforms
PureBasic

Example: Http.QuickGetSb method

Demonstrates the QuickGetSb method.

Chilkat PureBasic Downloads

PureBasic
IncludeFile "CkStringBuilder.pb"
IncludeFile "CkHttp.pb"

Procedure ChilkatExample()

    success.i = 0

    http.i = CkHttp::ckCreate()
    If http.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf

    ; Send the HTTP GET and return the content in a StringBuilder
    sb.i = CkStringBuilder::ckCreate()
    If sb.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf

    success = CkHttp::ckQuickGetSb(http,"https://www.chilkatsoft.com/helloWorld.json",sb)
    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 CkStringBuilder::ckGetAsString(sb)
        EndIf

        CkHttp::ckDispose(http)
        CkStringBuilder::ckDispose(sb)
        ProcedureReturn
    EndIf

    ; The downloaded content:
    Debug CkStringBuilder::ckGetAsString(sb)
    Debug "Success"


    CkHttp::ckDispose(http)
    CkStringBuilder::ckDispose(sb)


    ProcedureReturn
EndProcedure