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) 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
integer li_rc oleobject loo_Http integer li_Success oleobject loo_QueryParams oleobject loo_Resp oleobject loo_SbResponseBody oleobject loo_JResp integer li_RespStatusCode string ls_Id string ls_Brand_id string ls_Short_description string ls_Description integer li_Wholesale_price_cents integer li_Retail_price_cents string ls_Sale_state integer li_Active integer li_Deleted string ls_Name integer li_Unit_multiplier string ls_Taxonomy_typeId string ls_Taxonomy_typeName string ls_Created_at string ls_Updated_at integer j integer li_Count_j integer li_Page integer li_Limit integer i integer li_Count_i // This example assumes the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. loo_Http = create oleobject // Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0 li_rc = loo_Http.ConnectToNewObject("Chilkat.Http") if li_rc < 0 then destroy loo_Http MessageBox("Error","Connecting to COM object failed") return end if // 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 loo_QueryParams = create oleobject // Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0 li_rc = loo_QueryParams.ConnectToNewObject("Chilkat.JsonObject") loo_QueryParams.UpdateInt("limit",50) loo_QueryParams.UpdateInt("page",1) loo_Http.SetRequestHeader("X-FAIRE-ACCESS-TOKEN","<access_token>") loo_Resp = loo_Http.QuickRequestParams("GET","https://www.faire.com/api/v1/products",loo_QueryParams) if loo_Http.LastMethodSuccess = 0 then Write-Debug loo_Http.LastErrorText destroy loo_Http destroy loo_QueryParams return end if loo_SbResponseBody = create oleobject // Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0 li_rc = loo_SbResponseBody.ConnectToNewObject("Chilkat.StringBuilder") loo_Resp.GetBodySb(loo_SbResponseBody) loo_JResp = create oleobject // Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0 li_rc = loo_JResp.ConnectToNewObject("Chilkat.JsonObject") loo_JResp.LoadSb(loo_SbResponseBody) loo_JResp.EmitCompact = 0 Write-Debug "Response Body:" Write-Debug loo_JResp.Emit() li_RespStatusCode = loo_Resp.StatusCode Write-Debug "Response Status Code = " + string(li_RespStatusCode) if li_RespStatusCode >= 400 then Write-Debug "Response Header:" Write-Debug loo_Resp.Header Write-Debug "Failed." destroy loo_Resp destroy loo_Http destroy loo_QueryParams destroy loo_SbResponseBody destroy loo_JResp return end if destroy loo_Resp // 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 li_Page = loo_JResp.IntOf("page") li_Limit = loo_JResp.IntOf("limit") i = 0 li_Count_i = loo_JResp.SizeOfArray("products") do while i < li_Count_i loo_JResp.I = i ls_Id = loo_JResp.StringOf("products[i].id") ls_Brand_id = loo_JResp.StringOf("products[i].brand_id") ls_Short_description = loo_JResp.StringOf("products[i].short_description") ls_Description = loo_JResp.StringOf("products[i].description") li_Wholesale_price_cents = loo_JResp.IntOf("products[i].wholesale_price_cents") li_Retail_price_cents = loo_JResp.IntOf("products[i].retail_price_cents") ls_Sale_state = loo_JResp.StringOf("products[i].sale_state") li_Active = loo_JResp.BoolOf("products[i].active") li_Deleted = loo_JResp.BoolOf("products[i].deleted") ls_Name = loo_JResp.StringOf("products[i].name") li_Unit_multiplier = loo_JResp.IntOf("products[i].unit_multiplier") ls_Taxonomy_typeId = loo_JResp.StringOf("products[i].taxonomy_type.id") ls_Taxonomy_typeName = loo_JResp.StringOf("products[i].taxonomy_type.name") ls_Created_at = loo_JResp.StringOf("products[i].created_at") ls_Updated_at = loo_JResp.StringOf("products[i].updated_at") j = 0 li_Count_j = loo_JResp.SizeOfArray("products[i].options") do while j < li_Count_j loo_JResp.J = j j = j + 1 loop i = i + 1 loop destroy loo_Http destroy loo_QueryParams destroy loo_SbResponseBody destroy loo_JResp |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.