(Tcl) BrickLink OAuth1 using Chilkat HTTP
Demonstrates sending an api.bricklink.com request with OAuth1 authentication using Chilkat HTTP.
Note: This example requires Chilkat v9.5.0.91 or greater (due to adjustments made within Chilkat to support bricklink OAuth1 needs). For more information, see https://www.bricklink.com/v3/api.page?page=auth
load ./chilkat.dll
# This example assumes the Chilkat API to have been previously unlocked.
# See Global Unlock Sample for sample code.
set http [new_CkHttp]
CkHttp_put_OAuth1 $http 1
CkHttp_put_OAuthConsumerKey $http "Your Consumer Key"
CkHttp_put_OAuthConsumerSecret $http "Your Consumer Secret"
CkHttp_put_OAuthToken $http "Your OAuth1 Token"
CkHttp_put_OAuthTokenSecret $http "Your Token Secret"
CkHttp_put_OAuthSigMethod $http "HMAC-SHA1"
# resp is a CkHttpResponse
set resp [CkHttp_QuickGetObj $http "https://api.bricklink.com/api/store/v1/orders?direction=in"]
if {[CkHttp_get_LastMethodSuccess $http] == 0} then {
puts [CkHttp_lastErrorText $http]
delete_CkHttp $http
exit
}
puts "Response status code = [CkHttpResponse_get_StatusCode $resp]"
set json [new_CkJsonObject]
CkHttpResponse_GetBodyJson $resp $json
delete_CkHttpResponse $resp
CkJsonObject_put_EmitCompact $json 0
puts [CkJsonObject_emit $json]
delete_CkHttp $http
delete_CkJsonObject $json
|