Sample code for 30+ languages & platforms
PowerBuilder

BrickLink OAuth1 using Chilkat HTTP

See more BrickLink Examples

Demonstrates sending an api.bricklink.com request with OAuth1 authentication using Chilkat HTTP.

Chilkat PowerBuilder Downloads

PowerBuilder
integer li_rc
integer li_Success
oleobject loo_Http
oleobject loo_Resp
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_Http = create oleobject
li_rc = loo_Http.ConnectToNewObject("Chilkat.Http")
if li_rc < 0 then
    destroy loo_Http
    MessageBox("Error","Connecting to COM object failed")
    return
end if

loo_Http.OAuth1 = 1
loo_Http.OAuthConsumerKey = "Your Consumer Key"
loo_Http.OAuthConsumerSecret = "Your Consumer Secret"
loo_Http.OAuthToken = "Your OAuth1 Token"
loo_Http.OAuthTokenSecret = "Your Token Secret"
loo_Http.OAuthSigMethod = "HMAC-SHA1"

loo_Resp = create oleobject
li_rc = loo_Resp.ConnectToNewObject("Chilkat.HttpResponse")

li_Success = loo_Http.HttpNoBody("GET","https://api.bricklink.com/api/store/v1/orders?direction=in",loo_Resp)
if li_Success = 0 then
    Write-Debug loo_Http.LastErrorText
    destroy loo_Http
    destroy loo_Resp
    return
end if

Write-Debug "Response status code = " + string(loo_Resp.StatusCode)

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

loo_Resp.GetBodyJson(loo_Json)

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


destroy loo_Http
destroy loo_Resp
destroy loo_Json