Chilkat • HOME • Android™ • AutoIt • C • C# • C++ • Chilkat2-Python • CkPython • Classic ASP • DataFlex • Delphi DLL • Go • Java • Node.js • Objective-C • PHP Extension • Perl • PowerBuilder • PowerShell • PureBasic • Ruby • SQL Server • Swift • Tcl • Unicode C • Unicode C++ • VB.NET • VBScript • Visual Basic 6.0 • Visual FoxPro • Xojo Plugin
(Lianja) 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. loRest = createobject("CkRest") // See this example for getting an OAuth1 token for Etsy loJson = createobject("CkJsonObject") llSuccess = loJson.LoadFile("qa_data/tokens/etsy.json") if (llSuccess = .F.) then ? "Failed to load previously fetched Etsy OAuth1 access token." release loRest release loJson return endif loOauth1 = createobject("CkOAuth1") loOauth1.ConsumerKey = "app_keystring" loOauth1.ConsumerSecret = "app_shared_secret" loOauth1.Token = loJson.StringOf("oauth_token") loOauth1.TokenSecret = loJson.StringOf("oauth_token_secret") loOauth1.SignatureMethod = "HMAC-SHA1" loOauth1.GenNonce(16) llAutoReconnect = .T. llTls = .T. llSuccess = loRest.Connect("openapi.etsy.com",443,llTls,llAutoReconnect) if (llSuccess = .F.) then ? loRest.LastErrorText release loRest release loJson release loOauth1 return endif // Tell the REST object to use the OAuth1 object. llSuccess = loRest.SetAuthOAuth1(loOauth1,.T.) lcJsonText = '[{"product_id":1999949999,"property_values":[],"offerings":[{"offering_id":9999905883,"price":"36.23","quantity":1}]}]' loRest.AddQueryParam("products",lcJsonText) loRest.AddHeader("Content-Type","application/x-www-form-urlencoded") lcJsonResponseText = loRest.FullRequestFormUrlEncoded("PUT","/v2/listings/228827035/inventory") if (loRest.LastMethodSuccess = .F.) then ? loRest.LastErrorText release loRest release loJson release loOauth1 return endif loJsonResponse = createobject("CkJsonObject") loJsonResponse.Load(lcJsonResponseText) loJsonResponse.EmitCompact = .F. ? loJsonResponse.Emit() ? "Response status code: " + str(loRest.ResponseStatusCode) release loRest release loJson release loOauth1 release loJsonResponse |
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.