Sample code for 30+ languages & platforms
Lua Requires Chilkat v9.5.0.91+

BrickLink OAuth1 using Chilkat REST

See more BrickLink Examples

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

Chilkat Lua Downloads

Lua
local chilkat = require("chilkat")

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

local oauth1 = chilkat.OAuth1.new()

oauth1.consumer_key = "Your Consumer Key"
oauth1.consumer_secret = "Your Consumer Secret"
oauth1.token = "Your OAuth1 Token"
oauth1.token_secret = "Your Token Secret"
oauth1.signature_method = "HMAC-SHA1"

local rest = chilkat.Rest.new()

rest:set_auth_oauth1(oauth1, false)

local success = rest:connect("api.bricklink.com", 443, true, true)
if not success then
    print(rest.last_error_text)
    return
end

local sbResponse = chilkat.StringBuilder.new()
success = rest:full_request_no_body_sb("GET", "/api/store/v1/orders?direction=in", sbResponse)
if not success then
    print(rest.last_error_text)
    return
end

print("Response status code = " .. rest.response_status_code)

local json = chilkat.JsonObject.new()
json:load_sb(sbResponse)
json.emit_compact = false
print(json:emit())