(PureBasic) BrickLink OAuth1 using Chilkat HTTP
      Demonstrates sending an api.bricklink.com request with OAuth1 authentication using Chilkat HTTP.Note: This example requires Chilkat v11.0.0 or greater. For more information, see https://www.bricklink.com/v3/api.page?page=auth 
		
 
      IncludeFile "CkHttpResponse.pb"
IncludeFile "CkHttp.pb"
IncludeFile "CkJsonObject.pb"
Procedure ChilkatExample()
    success.i = 0
    ; This example assumes the Chilkat API to have been previously unlocked.
    ; See Global Unlock Sample for sample code.
    http.i = CkHttp::ckCreate()
    If http.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf
    CkHttp::setCkOAuth1(http, 1)
    CkHttp::setCkOAuthConsumerKey(http, "Your Consumer Key")
    CkHttp::setCkOAuthConsumerSecret(http, "Your Consumer Secret")
    CkHttp::setCkOAuthToken(http, "Your OAuth1 Token")
    CkHttp::setCkOAuthTokenSecret(http, "Your Token Secret")
    CkHttp::setCkOAuthSigMethod(http, "HMAC-SHA1")
    resp.i = CkHttpResponse::ckCreate()
    If resp.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf
    success = CkHttp::ckHttpNoBody(http,"GET","https://api.bricklink.com/api/store/v1/orders?direction=in",resp)
    If success = 0
        Debug CkHttp::ckLastErrorText(http)
        CkHttp::ckDispose(http)
        CkHttpResponse::ckDispose(resp)
        ProcedureReturn
    EndIf
    Debug "Response status code = " + Str(CkHttpResponse::ckStatusCode(resp))
    json.i = CkJsonObject::ckCreate()
    If json.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf
    CkHttpResponse::ckGetBodyJson(resp,json)
    CkJsonObject::setCkEmitCompact(json, 0)
    Debug CkJsonObject::ckEmit(json)
    CkHttp::ckDispose(http)
    CkHttpResponse::ckDispose(resp)
    CkJsonObject::ckDispose(json)
    ProcedureReturn
EndProcedure
     |