Xbase++
Xbase++
BrickLink OAuth1 using Chilkat REST
See more BrickLink Examples
Demonstrates sending an api.bricklink.com request with OAuth1 authentication using Chilkat REST.Note: This example requires Chilkat v9.5.0.91 or greater (due to adjustments made within Chilkat to support bricklink OAuth1 needs).
Chilkat Xbase++ Downloads
LOCAL nSuccess
LOCAL oOauth1
LOCAL oRest
LOCAL oSbResponse
LOCAL oJson
nSuccess := 0
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
oOauth1 := CreateObject("Chilkat.OAuth1")
oOauth1:ConsumerKey := "Your Consumer Key"
oOauth1:ConsumerSecret := "Your Consumer Secret"
oOauth1:Token := "Your OAuth1 Token"
oOauth1:TokenSecret := "Your Token Secret"
oOauth1:SignatureMethod := "HMAC-SHA1"
oRest := CreateObject("Chilkat.Rest")
oRest:SetAuthOAuth1(oOauth1, 0)
nSuccess := oRest:Connect("api.bricklink.com", 443, 1, 1)
IF (nSuccess == 0)
? oRest:LastErrorText
oOauth1:destroy()
oRest:destroy()
RETURN
ENDIF
oSbResponse := CreateObject("Chilkat.StringBuilder")
nSuccess := oRest:FullRequestNoBodySb("GET", "/api/store/v1/orders?direction=in", oSbResponse)
IF (nSuccess == 0)
? oRest:LastErrorText
oOauth1:destroy()
oRest:destroy()
oSbResponse:destroy()
RETURN
ENDIF
? "Response status code = " + Str(oRest:ResponseStatusCode)
oJson := CreateObject("Chilkat.JsonObject")
oJson:LoadSb(oSbResponse)
oJson:EmitCompact := 0
? oJson:Emit()
oOauth1:destroy()
oRest:destroy()
oSbResponse:destroy()
oJson:destroy()