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
(Visual FoxPro) Amazon SP-API Sellers Get Marketplace ParticipationsSee more Amazon SP-API ExamplesDemonstrates Amazon SP-API Sellers API -- get marketplace participations. For more information, see https://developer-docs.amazon.com/sp-api/docs/sellers-api-v1-reference#getmarketplaceparticipations
LOCAL loAuthAws LOCAL loRest LOCAL lnBTls LOCAL lnPort LOCAL lnBAutoReconnect LOCAL lnSuccess LOCAL loJsonToken LOCAL lcLwa_token LOCAL loSbResponse LOCAL lcUri LOCAL lnStatusCode LOCAL loJson LOCAL lcId LOCAL lcCountryCode LOCAL lcName LOCAL lcDefaultCurrencyCode LOCAL lcDefaultLanguageCode LOCAL lcDomainName LOCAL lnIsParticipating LOCAL lnHasSuspendedListings LOCAL i LOCAL lnCount_i * This example requires the Chilkat API to have been previously unlocked. * See Global Unlock Sample for sample code. * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.AuthAws') loAuthAws = CreateObject('Chilkat.AuthAws') loAuthAws.AccessKey = "AWS_ACCESS_KEY" loAuthAws.SecretKey = "AWS_SECRET_KEY" loAuthAws.ServiceName = "execute-api" * Use the region that is correct for your needs. loAuthAws.Region = "eu-west-1" * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.Rest') loRest = CreateObject('Chilkat.Rest') lnBTls = 1 lnPort = 443 lnBAutoReconnect = 1 * Make sure to use the correct domain. * In this example, we are using "sandbox.sellingpartnerapi-eu.amazon.com" lnSuccess = loRest.Connect("sandbox.sellingpartnerapi-eu.amazon.com",lnPort,lnBTls,lnBAutoReconnect) IF (lnSuccess = 0) THEN ? loRest.LastErrorText RELEASE loAuthAws RELEASE loRest CANCEL ENDIF lnSuccess = loRest.SetAuthAws(loAuthAws) * Load the previously obtained LWA access token. * See Fetch SP-API LWA Access Token * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.JsonObject') loJsonToken = CreateObject('Chilkat.JsonObject') lnSuccess = loJsonToken.LoadFile("qa_data/tokens/sp_api_lwa_token.json") IF (lnSuccess = 0) THEN ? "Failed to load LWA access token." RELEASE loAuthAws RELEASE loRest RELEASE loJsonToken CANCEL ENDIF * Add the x-amz-access-token request header. lcLwa_token = loJsonToken.StringOf("access_token") loRest.ClearAllHeaders() loRest.AddHeader("x-amz-access-token",lcLwa_token) * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.StringBuilder') loSbResponse = CreateObject('Chilkat.StringBuilder') lcUri = "/sellers/v1/marketplaceParticipations" lnSuccess = loRest.FullRequestNoBodySb("GET",lcUri,loSbResponse) IF (lnSuccess = 0) THEN ? loRest.LastErrorText RELEASE loAuthAws RELEASE loRest RELEASE loJsonToken RELEASE loSbResponse CANCEL ENDIF * Examine the response status. lnStatusCode = loRest.ResponseStatusCode IF (lnStatusCode <> 200) THEN ? "Response status text: " + loRest.ResponseStatusText ? "Response body: " ? loSbResponse.GetAsString() ? "Failed." RELEASE loAuthAws RELEASE loRest RELEASE loJsonToken RELEASE loSbResponse CANCEL ENDIF ? loSbResponse.GetAsString() * If successful, gets a JSON response such as the following: * { * "payload": [ * { * "marketplace": { * "id": "ATVPDKIKX0DER", * "countryCode": "US", * "name": "Amazon.com", * "defaultCurrencyCode": "USD", * "defaultLanguageCode": "en_US", * "domainName": "www.amazon.com" * }, * "participation": { * "isParticipating": true, * "hasSuspendedListings": false * } * } * ] * } * Use this online tool to generate parsing code from sample JSON: * Generate Parsing Code from JSON * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.JsonObject') loJson = CreateObject('Chilkat.JsonObject') loJson.LoadSb(loSbResponse) i = 0 lnCount_i = loJson.SizeOfArray("payload") DO WHILE i < lnCount_i loJson.I = i lcId = loJson.StringOf("payload[i].marketplace.id") lcCountryCode = loJson.StringOf("payload[i].marketplace.countryCode") lcName = loJson.StringOf("payload[i].marketplace.name") lcDefaultCurrencyCode = loJson.StringOf("payload[i].marketplace.defaultCurrencyCode") lcDefaultLanguageCode = loJson.StringOf("payload[i].marketplace.defaultLanguageCode") lcDomainName = loJson.StringOf("payload[i].marketplace.domainName") lnIsParticipating = loJson.BoolOf("payload[i].participation.isParticipating") lnHasSuspendedListings = loJson.BoolOf("payload[i].participation.hasSuspendedListings") i = i + 1 ENDDO ? "Success!" RELEASE loAuthAws RELEASE loRest RELEASE loJsonToken RELEASE loSbResponse RELEASE loJson |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.