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
(DataFlex) Shopify Get all products, showing only some attributesGet all products, showing only some attributes
Use ChilkatAx-win32.pkg Procedure Test Handle hoRest Boolean iSuccess Variant vSbJson Handle hoSbJson Handle hoJson Integer i Integer iCount_i Integer iId String sTitle Integer j Integer iCount_j Integer iProduct_id Integer iPosition String sCreated_at String sUpdated_at Integer iWidth Integer iHeight String sSrc Integer k Integer iCount_k Integer iIntVal String sTemp1 Integer iTemp1 Get Create (RefClass(cComChilkatRest)) To hoRest If (Not(IsComObjectCreated(hoRest))) Begin Send CreateComObject of hoRest End Get ComSetAuthBasic Of hoRest "SHOPIFY_PRIVATE_API_KEY" "SHOPIFY_PRIVATE_API_KEY" To iSuccess Get ComConnect Of hoRest "chilkat.myshopify.com" 443 True True To iSuccess If (iSuccess <> True) Begin Get ComLastErrorText Of hoRest To sTemp1 Showln sTemp1 Procedure_Return End Get Create (RefClass(cComChilkatStringBuilder)) To hoSbJson If (Not(IsComObjectCreated(hoSbJson))) Begin Send CreateComObject of hoSbJson End Get pvComObject of hoSbJson to vSbJson Get ComFullRequestNoBodySb Of hoRest "GET" "/admin/products.json?fields=id,images,title" vSbJson To iSuccess If (iSuccess <> True) Begin Get ComLastErrorText Of hoRest To sTemp1 Showln sTemp1 Procedure_Return End Get ComResponseStatusCode Of hoRest To iTemp1 If (iTemp1 <> 200) Begin Get ComResponseStatusCode Of hoRest To iTemp1 Showln "Received error response code: " iTemp1 Showln "Response body:" Get ComGetAsString Of hoSbJson To sTemp1 Showln sTemp1 Procedure_Return End Get Create (RefClass(cComChilkatJsonObject)) To hoJson If (Not(IsComObjectCreated(hoJson))) Begin Send CreateComObject of hoJson End Get pvComObject of hoSbJson to vSbJson Get ComLoadSb Of hoJson vSbJson To iSuccess // The following code parses the JSON response. // A sample JSON response is shown below the sample code. Move 0 To i Get ComSizeOfArray Of hoJson "products" To iCount_i While (i < iCount_i) Set ComI Of hoJson To i Get ComIntOf Of hoJson "products[i].id" To iId Get ComStringOf Of hoJson "products[i].title" To sTitle Move 0 To j Get ComSizeOfArray Of hoJson "products[i].images" To iCount_j While (j < iCount_j) Set ComJ Of hoJson To j Get ComIntOf Of hoJson "products[i].images[j].id" To iId Get ComIntOf Of hoJson "products[i].images[j].product_id" To iProduct_id Get ComIntOf Of hoJson "products[i].images[j].position" To iPosition Get ComStringOf Of hoJson "products[i].images[j].created_at" To sCreated_at Get ComStringOf Of hoJson "products[i].images[j].updated_at" To sUpdated_at Get ComIntOf Of hoJson "products[i].images[j].width" To iWidth Get ComIntOf Of hoJson "products[i].images[j].height" To iHeight Get ComStringOf Of hoJson "products[i].images[j].src" To sSrc Move 0 To k Get ComSizeOfArray Of hoJson "products[i].images[j].variant_ids" To iCount_k While (k < iCount_k) Set ComK Of hoJson To k Get ComIntOf Of hoJson "products[i].images[j].variant_ids[k]" To iIntVal Move (k + 1) To k Loop Move (j + 1) To j Loop Move (i + 1) To i Loop // A sample JSON response body that is parsed by the above code: // { // "products": [ // { // "id": 632910392, // "title": "IPod Nano - 8GB", // "images": [ // { // "id": 850703190, // "product_id": 632910392, // "position": 1, // "created_at": "2017-09-22T14:08:02-04:00", // "updated_at": "2017-09-22T14:08:02-04:00", // "width": 123, // "height": 456, // "src": "https:\/\/cdn.shopify.com\/s\/files\/1\/0006\/9093\/3842\/products\/ipod-nano.png?v=1506103682", // "variant_ids": [ // ] // }, // { // "id": 562641783, // "product_id": 632910392, // "position": 2, // "created_at": "2017-09-22T14:08:02-04:00", // "updated_at": "2017-09-22T14:08:02-04:00", // "width": 123, // "height": 456, // "src": "https:\/\/cdn.shopify.com\/s\/files\/1\/0006\/9093\/3842\/products\/ipod-nano-2.png?v=1506103682", // "variant_ids": [ // 808950810 // ] // } // ] // }, // { // "id": 921728736, // "title": "IPod Touch 8GB", // "images": [ // ] // } // ] // } Showln "Example Completed." End_Procedure |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.