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
(PowerBuilder) 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.
integer li_rc oleobject loo_Rest integer li_Success oleobject loo_Json oleobject loo_Oauth1 integer li_AutoReconnect integer li_Tls string ls_JsonText string ls_JsonResponseText oleobject loo_JsonResponse // This example assumes the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. loo_Rest = create oleobject // Use "Chilkat_9_5_0.Rest" for versions of Chilkat < 10.0.0 li_rc = loo_Rest.ConnectToNewObject("Chilkat.Rest") if li_rc < 0 then destroy loo_Rest MessageBox("Error","Connecting to COM object failed") return end if // See this example for getting an OAuth1 token for Etsy loo_Json = create oleobject // Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0 li_rc = loo_Json.ConnectToNewObject("Chilkat.JsonObject") li_Success = loo_Json.LoadFile("qa_data/tokens/etsy.json") if li_Success = 0 then Write-Debug "Failed to load previously fetched Etsy OAuth1 access token." destroy loo_Rest destroy loo_Json return end if loo_Oauth1 = create oleobject // Use "Chilkat_9_5_0.OAuth1" for versions of Chilkat < 10.0.0 li_rc = loo_Oauth1.ConnectToNewObject("Chilkat.OAuth1") loo_Oauth1.ConsumerKey = "app_keystring" loo_Oauth1.ConsumerSecret = "app_shared_secret" loo_Oauth1.Token = loo_Json.StringOf("oauth_token") loo_Oauth1.TokenSecret = loo_Json.StringOf("oauth_token_secret") loo_Oauth1.SignatureMethod = "HMAC-SHA1" loo_Oauth1.GenNonce(16) li_AutoReconnect = 1 li_Tls = 1 li_Success = loo_Rest.Connect("openapi.etsy.com",443,li_Tls,li_AutoReconnect) if li_Success = 0 then Write-Debug loo_Rest.LastErrorText destroy loo_Rest destroy loo_Json destroy loo_Oauth1 return end if // Tell the REST object to use the OAuth1 object. li_Success = loo_Rest.SetAuthOAuth1(loo_Oauth1,1) ls_JsonText = "[{~"product_id~":1999949999,~"property_values~":[],~"offerings~":[{~"offering_id~":9999905883,~"price~":~"36.23~",~"quantity~":1}]}]" loo_Rest.AddQueryParam("products",ls_JsonText) loo_Rest.AddHeader("Content-Type","application/x-www-form-urlencoded") ls_JsonResponseText = loo_Rest.FullRequestFormUrlEncoded("PUT","/v2/listings/228827035/inventory") if loo_Rest.LastMethodSuccess = 0 then Write-Debug loo_Rest.LastErrorText destroy loo_Rest destroy loo_Json destroy loo_Oauth1 return end if loo_JsonResponse = create oleobject // Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0 li_rc = loo_JsonResponse.ConnectToNewObject("Chilkat.JsonObject") loo_JsonResponse.Load(ls_JsonResponseText) loo_JsonResponse.EmitCompact = 0 Write-Debug loo_JsonResponse.Emit() Write-Debug "Response status code: " + string(loo_Rest.ResponseStatusCode) destroy loo_Rest destroy loo_Json destroy loo_Oauth1 destroy loo_JsonResponse |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.