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) Faire - Get All ProductsSee more Faire ExamplesRetrieves a list of products, ordered ascending by updated_at. By default, it only returns non-deleted products. For more information, see https://faire.github.io/external-api-docs/#get-all-products
LOCAL loHttp LOCAL lnSuccess LOCAL loQueryParams LOCAL loResp LOCAL loSbResponseBody LOCAL loJResp LOCAL lnRespStatusCode LOCAL lcId LOCAL lcBrand_id LOCAL lcShort_description LOCAL lcDescription LOCAL lnWholesale_price_cents LOCAL lnRetail_price_cents LOCAL lcSale_state LOCAL lnActive LOCAL lnDeleted LOCAL lcName LOCAL lnUnit_multiplier LOCAL lcTaxonomy_typeId LOCAL lcTaxonomy_typeName LOCAL lcCreated_at LOCAL lcUpdated_at LOCAL j LOCAL lnCount_j LOCAL lnPage LOCAL lnLimit LOCAL i LOCAL lnCount_i * This example assumes 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.Http') loHttp = CreateObject('Chilkat.Http') * Implements the following CURL command: * curl -X GET -H "X-FAIRE-ACCESS-TOKEN: <access_token>" -d "limit=50" -d "page=1" https://www.faire.com/api/v1/products * Use the following online tool to generate HTTP code from a CURL command * Convert a cURL Command to HTTP Source Code * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.JsonObject') loQueryParams = CreateObject('Chilkat.JsonObject') loQueryParams.UpdateInt("limit",50) loQueryParams.UpdateInt("page",1) loHttp.SetRequestHeader("X-FAIRE-ACCESS-TOKEN","<access_token>") loResp = loHttp.QuickRequestParams("GET","https://www.faire.com/api/v1/products",loQueryParams) IF (loHttp.LastMethodSuccess = 0) THEN ? loHttp.LastErrorText RELEASE loHttp RELEASE loQueryParams CANCEL ENDIF * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.StringBuilder') loSbResponseBody = CreateObject('Chilkat.StringBuilder') loResp.GetBodySb(loSbResponseBody) * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.JsonObject') loJResp = CreateObject('Chilkat.JsonObject') loJResp.LoadSb(loSbResponseBody) loJResp.EmitCompact = 0 ? "Response Body:" ? loJResp.Emit() lnRespStatusCode = loResp.StatusCode ? "Response Status Code = " + STR(lnRespStatusCode) IF (lnRespStatusCode >= 400) THEN ? "Response Header:" ? loResp.Header ? "Failed." RELEASE loResp RELEASE loHttp RELEASE loQueryParams RELEASE loSbResponseBody RELEASE loJResp CANCEL ENDIF RELEASE loResp * Sample JSON response: * (Sample code for parsing the JSON response is shown below) * { * "page": 1, * "limit": 50, * "products": [ * { * "id": "p_123", * "brand_id": "b_abc", * "short_description": "Our candles smell fantastic. Want to know how good? Read our description!", * "description": "Glad you decided to read our description! We have significantly more characters to describe to you just how good our candles smell.", * "wholesale_price_cents": 500, * "retail_price_cents": 1000, * "sale_state": "FOR_SALE", * "active": true, * "deleted": false, * "name": "Faire's fantastic candle", * "unit_multiplier": 8, * "taxonomy_type": { * "id": "tt_23nl3bzl00", * "name": "Votive Candle" * }, * "options": [ * ], * "created_at": "20190314T000915.000Z", * "updated_at": "20190315T000915.000Z" * } * ] * } * Sample code for parsing the JSON response... * Use the following online tool to generate parsing code from sample JSON: * Generate Parsing Code from JSON lnPage = loJResp.IntOf("page") lnLimit = loJResp.IntOf("limit") i = 0 lnCount_i = loJResp.SizeOfArray("products") DO WHILE i < lnCount_i loJResp.I = i lcId = loJResp.StringOf("products[i].id") lcBrand_id = loJResp.StringOf("products[i].brand_id") lcShort_description = loJResp.StringOf("products[i].short_description") lcDescription = loJResp.StringOf("products[i].description") lnWholesale_price_cents = loJResp.IntOf("products[i].wholesale_price_cents") lnRetail_price_cents = loJResp.IntOf("products[i].retail_price_cents") lcSale_state = loJResp.StringOf("products[i].sale_state") lnActive = loJResp.BoolOf("products[i].active") lnDeleted = loJResp.BoolOf("products[i].deleted") lcName = loJResp.StringOf("products[i].name") lnUnit_multiplier = loJResp.IntOf("products[i].unit_multiplier") lcTaxonomy_typeId = loJResp.StringOf("products[i].taxonomy_type.id") lcTaxonomy_typeName = loJResp.StringOf("products[i].taxonomy_type.name") lcCreated_at = loJResp.StringOf("products[i].created_at") lcUpdated_at = loJResp.StringOf("products[i].updated_at") j = 0 lnCount_j = loJResp.SizeOfArray("products[i].options") DO WHILE j < lnCount_j loJResp.J = j j = j + 1 ENDDO i = i + 1 ENDDO RELEASE loHttp RELEASE loQueryParams RELEASE loSbResponseBody RELEASE loJResp |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.