(Tcl) BrickLink OAuth1 using Chilkat HTTP
Demonstrates sending an api.bricklink.com request with OAuth1 authentication using Chilkat HTTP.Note: This example requires Chilkat v11.0.0 or greater. For more information, see https://www.bricklink.com/v3/api.page?page=auth
load ./chilkat.dll
set success 0
# 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"
set resp [new_CkHttpResponse]
set success [CkHttp_HttpNoBody $http "GET" "https://api.bricklink.com/api/store/v1/orders?direction=in" $resp]
if {$success == 0} then {
puts [CkHttp_lastErrorText $http]
delete_CkHttp $http
delete_CkHttpResponse $resp
exit
}
puts "Response status code = [CkHttpResponse_get_StatusCode $resp]"
set json [new_CkJsonObject]
CkHttpResponse_GetBodyJson $resp $json
CkJsonObject_put_EmitCompact $json 0
puts [CkJsonObject_emit $json]
delete_CkHttp $http
delete_CkHttpResponse $resp
delete_CkJsonObject $json
|