Sample code for 30+ languages & platforms
PowerBuilder

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 PowerBuilder Downloads

PowerBuilder
integer li_rc
integer li_Success
oleobject loo_Oauth1
oleobject loo_Rest
oleobject loo_SbResponse
oleobject loo_Json

li_Success = 0

// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.

loo_Oauth1 = create oleobject
li_rc = loo_Oauth1.ConnectToNewObject("Chilkat.OAuth1")
if li_rc < 0 then
    destroy loo_Oauth1
    MessageBox("Error","Connecting to COM object failed")
    return
end if

loo_Oauth1.ConsumerKey = "Your Consumer Key"
loo_Oauth1.ConsumerSecret = "Your Consumer Secret"
loo_Oauth1.Token = "Your OAuth1 Token"
loo_Oauth1.TokenSecret = "Your Token Secret"
loo_Oauth1.SignatureMethod = "HMAC-SHA1"

loo_Rest = create oleobject
li_rc = loo_Rest.ConnectToNewObject("Chilkat.Rest")

loo_Rest.SetAuthOAuth1(loo_Oauth1,0)

li_Success = loo_Rest.Connect("api.bricklink.com",443,1,1)
if li_Success = 0 then
    Write-Debug loo_Rest.LastErrorText
    destroy loo_Oauth1
    destroy loo_Rest
    return
end if

loo_SbResponse = create oleobject
li_rc = loo_SbResponse.ConnectToNewObject("Chilkat.StringBuilder")

li_Success = loo_Rest.FullRequestNoBodySb("GET","/api/store/v1/orders?direction=in",loo_SbResponse)
if li_Success = 0 then
    Write-Debug loo_Rest.LastErrorText
    destroy loo_Oauth1
    destroy loo_Rest
    destroy loo_SbResponse
    return
end if

Write-Debug "Response status code = " + string(loo_Rest.ResponseStatusCode)

loo_Json = create oleobject
li_rc = loo_Json.ConnectToNewObject("Chilkat.JsonObject")

loo_Json.LoadSb(loo_SbResponse)
loo_Json.EmitCompact = 0
Write-Debug loo_Json.Emit()


destroy loo_Oauth1
destroy loo_Rest
destroy loo_SbResponse
destroy loo_Json