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
(AutoIt) 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.
; This example assumes the Chilkat API to have been previously unlocked. ; See Global Unlock Sample for sample code. $oRest = ObjCreate("Chilkat.Rest") Local $bSuccess ; See this example for getting an OAuth1 token for Etsy $oJson = ObjCreate("Chilkat.JsonObject") $bSuccess = $oJson.LoadFile("qa_data/tokens/etsy.json") If ($bSuccess = False) Then ConsoleWrite("Failed to load previously fetched Etsy OAuth1 access token." & @CRLF) Exit EndIf $oOauth1 = ObjCreate("Chilkat.OAuth1") $oOauth1.ConsumerKey = "app_keystring" $oOauth1.ConsumerSecret = "app_shared_secret" $oOauth1.Token = $oJson.StringOf("oauth_token") $oOauth1.TokenSecret = $oJson.StringOf("oauth_token_secret") $oOauth1.SignatureMethod = "HMAC-SHA1" $oOauth1.GenNonce(16) Local $bAutoReconnect = True Local $bTls = True $bSuccess = $oRest.Connect("openapi.etsy.com",443,$bTls,$bAutoReconnect) If ($bSuccess = False) Then ConsoleWrite($oRest.LastErrorText & @CRLF) Exit EndIf ; Tell the REST object to use the OAuth1 object. $bSuccess = $oRest.SetAuthOAuth1($oOauth1,True) Local $sJsonText = "[{""product_id"":1999949999,""property_values"":[],""offerings"":[{""offering_id"":9999905883,""price"":""36.23"",""quantity"":1}]}]" $oRest.AddQueryParam("products",$sJsonText) $oRest.AddHeader("Content-Type","application/x-www-form-urlencoded") Local $sJsonResponseText = $oRest.FullRequestFormUrlEncoded("PUT","/v2/listings/228827035/inventory") If ($oRest.LastMethodSuccess = False) Then ConsoleWrite($oRest.LastErrorText & @CRLF) Exit EndIf $oJsonResponse = ObjCreate("Chilkat.JsonObject") $oJsonResponse.Load($sJsonResponseText) $oJsonResponse.EmitCompact = False ConsoleWrite($oJsonResponse.Emit() & @CRLF) ConsoleWrite("Response status code: " & $oRest.ResponseStatusCode & @CRLF) |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.