Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(Tcl) Update an Inventory Listing using OAuth1 AuthenticationSee more Etsy ExamplesUpdates an inventory listing. This example uses OAuth1 authentication instead of providing an api_key=MY_ETSY_KEYSTRING query parameter.
load ./chilkat.dll # This example assumes the Chilkat API to have been previously unlocked. # See Global Unlock Sample for sample code. set rest [new_CkRest] # See this example for getting an OAuth1 token for Etsy set json [new_CkJsonObject] set success [CkJsonObject_LoadFile $json "qa_data/tokens/etsy.json"] if {$success == 0} then { puts "Failed to load previously fetched Etsy OAuth1 access token." delete_CkRest $rest delete_CkJsonObject $json exit } set oauth1 [new_CkOAuth1] CkOAuth1_put_ConsumerKey $oauth1 "app_keystring" CkOAuth1_put_ConsumerSecret $oauth1 "app_shared_secret" CkOAuth1_put_Token $oauth1 [CkJsonObject_stringOf $json "oauth_token"] CkOAuth1_put_TokenSecret $oauth1 [CkJsonObject_stringOf $json "oauth_token_secret"] CkOAuth1_put_SignatureMethod $oauth1 "HMAC-SHA1" CkOAuth1_GenNonce $oauth1 16 set autoReconnect 1 set tls 1 set success [CkRest_Connect $rest "openapi.etsy.com" 443 $tls $autoReconnect] if {$success == 0} then { puts [CkRest_lastErrorText $rest] delete_CkRest $rest delete_CkJsonObject $json delete_CkOAuth1 $oauth1 exit } # Tell the REST object to use the OAuth1 object. set success [CkRest_SetAuthOAuth1 $rest $oauth1 1] set jsonText "[{\"product_id\":1999949999,\"property_values\":[],\"offerings\":[{\"offering_id\":9999905883,\"price\":\"36.23\",\"quantity\":1}]}]" CkRest_AddQueryParam $rest "products" $jsonText CkRest_AddHeader $rest "Content-Type" "application/x-www-form-urlencoded" set jsonResponseText [CkRest_fullRequestFormUrlEncoded $rest "PUT" "/v2/listings/228827035/inventory"] if {[CkRest_get_LastMethodSuccess $rest] == 0} then { puts [CkRest_lastErrorText $rest] delete_CkRest $rest delete_CkJsonObject $json delete_CkOAuth1 $oauth1 exit } set jsonResponse [new_CkJsonObject] CkJsonObject_Load $jsonResponse $jsonResponseText CkJsonObject_put_EmitCompact $jsonResponse 0 puts [CkJsonObject_emit $jsonResponse] puts "Response status code: [CkRest_get_ResponseStatusCode $rest]" delete_CkRest $rest delete_CkJsonObject $json delete_CkOAuth1 $oauth1 delete_CkJsonObject $jsonResponse |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.