(Tcl) Magento Request with OAuth1.0a Authentication
Demonstrates sending a Magento request with OAuth1.0a authentication. (Using the Magento 1.x REST API)
load ./chilkat.dll
# This example requires 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_OAuthVerifier $http ""
CkHttp_put_OAuthConsumerKey $http "MAGENTO_CONSUMER_KEY"
CkHttp_put_OAuthConsumerSecret $http "MAGENTO_CONSUMER_SECRET"
CkHttp_put_OAuthToken $http "MAGENTO__TOKEN"
CkHttp_put_OAuthTokenSecret $http "MAGENTO_TOKEN_SECRET"
CkHttp_put_Accept $http "application/json"
set url "http://www.inart.com/api/rest/products/store/2?limit=20&page=1"
set jsonStr [CkHttp_quickGetStr $http $url]
if {[CkHttp_get_LastMethodSuccess $http] != 1} then {
puts [CkHttp_lastErrorText $http]
delete_CkHttp $http
exit
}
puts "Response status code = [CkHttp_get_LastStatus $http]"
set json [new_CkJsonObject]
CkJsonObject_Load $json $jsonStr
CkJsonObject_put_EmitCompact $json 0
puts [CkJsonObject_emit $json]
# Use this online tool to generate parsing code from sample JSON:
# Generate Parsing Code from JSON
delete_CkHttp $http
delete_CkJsonObject $json
|