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) WooCommerce List All ProductsSee more WooCommerce ExamplesGets WooCommerce product information in JSON format. For more information, see https://woocommerce.github.io/woocommerce-rest-api-docs/#list-all-products
Use ChilkatAx-win32.pkg Procedure Test Handle hoHttp Boolean iSuccess Variant vSbResponseBody Handle hoSbResponseBody Handle hoJarrResp Integer iRespStatusCode Variant vDate_created Handle hoDate_created Variant vDate_created_gmt Handle hoDate_created_gmt Variant vDate_modified Handle hoDate_modified Variant vDate_modified _gmt Handle hoDate_modified_gmt Variant vDate_on_sale_from Handle hoDate_on_sale_from Variant vDate_on_sale_from _gmt Handle hoDate_on_sale_from_gmt Variant vDate_on_sale_to Handle hoDate_on_sale_to Variant vDate_on_sale_to_gmt Handle hoDate_on_sale_to_gmt Variant vJson Handle hoJson Integer iId String sName String sSlug String sPermalink String sV_type String sStatus Boolean iFeatured String sCatalog_visibility String sDescription String sShort_description String sSku String sPrice String sRegular_price String sSale_price String sPrice_html Boolean iOn_sale Boolean iPurchasable Integer iTotal_sales Boolean iV_virtual Boolean iDownloadable Integer iDownload_limit Integer iDownload_expiry String sExternal_url String sButton_text String sTax_status String sTax_class Boolean iManage_stock String sStock_quantity String sStock_status String sBackorders Boolean iBackorders_allowed Boolean iBackordered Boolean iSold_individually String sWeight String sDimensionsLength String sDimensionsWidth String sDimensionsHeight Boolean iShipping_required Boolean iShipping_taxable String sShipping_class Integer iShipping_class_id Boolean iReviews_allowed String sAverage_rating Integer iRating_count Integer iParent_id String sPurchase_note Integer iMenu_order Integer j Integer iCount_j Integer iIntVal String sSrc String sAlt Integer iPosition Boolean iVisible Boolean iVariation Integer k Integer iCount_k String sStrVal String sV_option String sHref Integer i Integer iCount_i String sTemp1 // This example assumes the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. Get Create (RefClass(cComChilkatHttp)) To hoHttp If (Not(IsComObjectCreated(hoHttp))) Begin Send CreateComObject of hoHttp End // Implements the following CURL command: // curl https://example.com/wp-json/wc/v3/products \ // -u consumer_key:consumer_secret // Use the following online tool to generate HTTP code from a CURL command // Convert a cURL Command to HTTP Source Code Set ComBasicAuth Of hoHttp To True Set ComLogin Of hoHttp To "consumer_key" Set ComPassword Of hoHttp To "consumer_secret" Get Create (RefClass(cComChilkatStringBuilder)) To hoSbResponseBody If (Not(IsComObjectCreated(hoSbResponseBody))) Begin Send CreateComObject of hoSbResponseBody End Get pvComObject of hoSbResponseBody to vSbResponseBody Get ComQuickGetSb Of hoHttp "https://example.com/wp-json/wc/v3/products" vSbResponseBody To iSuccess If (iSuccess = False) Begin Get ComLastErrorText Of hoHttp To sTemp1 Showln sTemp1 Procedure_Return End Get Create (RefClass(cComChilkatJsonArray)) To hoJarrResp If (Not(IsComObjectCreated(hoJarrResp))) Begin Send CreateComObject of hoJarrResp End Get pvComObject of hoSbResponseBody to vSbResponseBody Get ComLoadSb Of hoJarrResp vSbResponseBody To iSuccess Set ComEmitCompact Of hoJarrResp To False Showln "Response Body:" Get ComEmit Of hoJarrResp To sTemp1 Showln sTemp1 Get ComLastStatus Of hoHttp To iRespStatusCode Showln "Response Status Code = " iRespStatusCode If (iRespStatusCode >= 400) Begin Showln "Response Header:" Get ComLastHeader Of hoHttp To sTemp1 Showln sTemp1 Showln "Failed." Procedure_Return End // Sample JSON response: // (Sample code for parsing the JSON response is shown below) // [ // { // "id": 799, // "name": "Ship Your Idea", // "slug": "ship-your-idea-22", // "permalink": "https://example.com/product/ship-your-idea-22/", // "date_created": "2017-03-23T17:03:12", // "date_created_gmt": "2017-03-23T20:03:12", // "date_modified": "2017-03-23T17:03:12", // "date_modified_gmt": "2017-03-23T20:03:12", // "type": "variable", // "status": "publish", // "featured": false, // "catalog_visibility": "visible", // "description": "<p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.</p>\n", // "short_description": "<p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.</p>\n", // "sku": "", // "price": "", // "regular_price": "", // "sale_price": "", // "date_on_sale_from": null, // "date_on_sale_from_gmt": null, // "date_on_sale_to": null, // "date_on_sale_to_gmt": null, // "price_html": "", // "on_sale": false, // "purchasable": false, // "total_sales": 0, // "virtual": false, // "downloadable": false, // "downloads": [ // ], // "download_limit": -1, // "download_expiry": -1, // "external_url": "", // "button_text": "", // "tax_status": "taxable", // "tax_class": "", // "manage_stock": false, // "stock_quantity": null, // "stock_status": "instock", // "backorders": "no", // "backorders_allowed": false, // "backordered": false, // "sold_individually": false, // "weight": "", // "dimensions": { // "length": "", // "width": "", // "height": "" // }, // "shipping_required": true, // "shipping_taxable": true, // "shipping_class": "", // "shipping_class_id": 0, // "reviews_allowed": true, // "average_rating": "0.00", // "rating_count": 0, // "related_ids": [ // 31, // 22, // 369, // 414, // 56 // ], // "upsell_ids": [ // ], // "cross_sell_ids": [ // ], // "parent_id": 0, // "purchase_note": "", // "categories": [ // { // "id": 9, // "name": "Clothing", // "slug": "clothing" // }, // { // "id": 14, // "name": "T-shirts", // "slug": "t-shirts" // } // ], // "tags": [ // ], // "images": [ // { // "id": 795, // "date_created": "2017-03-23T14:03:08", // "date_created_gmt": "2017-03-23T20:03:08", // "date_modified": "2017-03-23T14:03:08", // "date_modified_gmt": "2017-03-23T20:03:08", // "src": "https://example.com/wp-content/uploads/2017/03/T_4_front-11.jpg", // "name": "", // "alt": "" // }, // { // "id": 796, // "date_created": "2017-03-23T14:03:09", // "date_created_gmt": "2017-03-23T20:03:09", // "date_modified": "2017-03-23T14:03:09", // "date_modified_gmt": "2017-03-23T20:03:09", // "src": "https://example.com/wp-content/uploads/2017/03/T_4_back-10.jpg", // "name": "", // "alt": "" // }, // { // "id": 797, // "date_created": "2017-03-23T14:03:10", // "date_created_gmt": "2017-03-23T20:03:10", // "date_modified": "2017-03-23T14:03:10", // "date_modified_gmt": "2017-03-23T20:03:10", // "src": "https://example.com/wp-content/uploads/2017/03/T_3_front-10.jpg", // "name": "", // "alt": "" // }, // { // "id": 798, // "date_created": "2017-03-23T14:03:11", // "date_created_gmt": "2017-03-23T20:03:11", // "date_modified": "2017-03-23T14:03:11", // "date_modified_gmt": "2017-03-23T20:03:11", // "src": "https://example.com/wp-content/uploads/2017/03/T_3_back-10.jpg", // "name": "", // "alt": "" // } // ], // "attributes": [ // { // "id": 6, // "name": "Color", // "position": 0, // "visible": false, // "variation": true, // "options": [ // "Black", // "Green" // ] // }, // { // "id": 0, // "name": "Size", // "position": 0, // "visible": true, // "variation": true, // "options": [ // "S", // "M" // ] // } // ], // "default_attributes": [ // ], // "variations": [ // ], // "grouped_products": [ // ], // "menu_order": 0, // "meta_data": [ // ], // "_links": { // "self": [ // { // "href": "https://example.com/wp-json/wc/v3/products/799" // } // ], // "collection": [ // { // "href": "https://example.com/wp-json/wc/v3/products" // } // ] // } // }, // { // "id": 794, // "name": "Premium Quality", // "slug": "premium-quality-19", // "permalink": "https://example.com/product/premium-quality-19/", // "date_created": "2017-03-23T17:01:14", // "date_created_gmt": "2017-03-23T20:01:14", // "date_modified": "2017-03-23T17:01:14", // "date_modified_gmt": "2017-03-23T20:01:14", // "type": "simple", // "status": "publish", // "featured": false, // "catalog_visibility": "visible", // "description": "<p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.</p>\n", // "short_description": "<p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.</p>\n", // "sku": "", // "price": "21.99", // "regular_price": "21.99", // "sale_price": "", // "date_on_sale_from": null, // "date_on_sale_from_gmt": null, // "date_on_sale_to": null, // "date_on_sale_to_gmt": null, // "price_html": "<span class=\"woocommerce-Price-amount amount\"><span class=\"woocommerce-Price-currencySymbol\">$</span>21.99</span>", // "on_sale": false, // "purchasable": true, // "total_sales": 0, // "virtual": false, // "downloadable": false, // "downloads": [ // ], // "download_limit": -1, // "download_expiry": -1, // "external_url": "", // "button_text": "", // "tax_status": "taxable", // "tax_class": "", // "manage_stock": false, // "stock_quantity": null, // "stock_status": "instock", // "backorders": "no", // "backorders_allowed": false, // "backordered": false, // "sold_individually": false, // "weight": "", // "dimensions": { // "length": "", // "width": "", // "height": "" // }, // "shipping_required": true, // "shipping_taxable": true, // "shipping_class": "", // "shipping_class_id": 0, // "reviews_allowed": true, // "average_rating": "0.00", // "rating_count": 0, // "related_ids": [ // 463, // 47, // 31, // 387, // 458 // ], // "upsell_ids": [ // ], // "cross_sell_ids": [ // ], // "parent_id": 0, // "purchase_note": "", // "categories": [ // { // "id": 9, // "name": "Clothing", // "slug": "clothing" // }, // { // "id": 14, // "name": "T-shirts", // "slug": "t-shirts" // } // ], // "tags": [ // ], // "images": [ // { // "id": 792, // "date_created": "2017-03-23T14:01:13", // "date_created_gmt": "2017-03-23T20:01:13", // "date_modified": "2017-03-23T14:01:13", // "date_modified_gmt": "2017-03-23T20:01:13", // "src": "https://example.com/wp-content/uploads/2017/03/T_2_front-4.jpg", // "name": "", // "alt": "" // }, // { // "id": 793, // "date_created": "2017-03-23T14:01:14", // "date_created_gmt": "2017-03-23T20:01:14", // "date_modified": "2017-03-23T14:01:14", // "date_modified_gmt": "2017-03-23T20:01:14", // "src": "https://example.com/wp-content/uploads/2017/03/T_2_back-2.jpg", // "name": "", // "alt": "" // } // ], // "attributes": [ // ], // "default_attributes": [ // { // "id": 6, // "name": "Color", // "option": "black" // }, // { // "id": 0, // "name": "Size", // "option": "S" // } // ], // "variations": [ // ], // "grouped_products": [ // ], // "menu_order": 0, // "meta_data": [ // ], // "_links": { // "self": [ // { // "href": "https://example.com/wp-json/wc/v3/products/794" // } // ], // "collection": [ // { // "href": "https://example.com/wp-json/wc/v3/products" // } // ] // } // } // ] // Sample code for parsing the JSON response... // Use the following online tool to generate parsing code from sample JSON: // Generate Parsing Code from JSON Get Create (RefClass(cComChilkatDtObj)) To hoDate_created If (Not(IsComObjectCreated(hoDate_created))) Begin Send CreateComObject of hoDate_created End Get Create (RefClass(cComChilkatDtObj)) To hoDate_created_gmt If (Not(IsComObjectCreated(hoDate_created_gmt))) Begin Send CreateComObject of hoDate_created_gmt End Get Create (RefClass(cComChilkatDtObj)) To hoDate_modified If (Not(IsComObjectCreated(hoDate_modified))) Begin Send CreateComObject of hoDate_modified End Get Create (RefClass(cComChilkatDtObj)) To hoDate_modified_gmt If (Not(IsComObjectCreated(hoDate_modified_gmt))) Begin Send CreateComObject of hoDate_modified_gmt End Get Create (RefClass(cComChilkatDtObj)) To hoDate_on_sale_from If (Not(IsComObjectCreated(hoDate_on_sale_from))) Begin Send CreateComObject of hoDate_on_sale_from End Get Create (RefClass(cComChilkatDtObj)) To hoDate_on_sale_from_gmt If (Not(IsComObjectCreated(hoDate_on_sale_from_gmt))) Begin Send CreateComObject of hoDate_on_sale_from_gmt End Get Create (RefClass(cComChilkatDtObj)) To hoDate_on_sale_to If (Not(IsComObjectCreated(hoDate_on_sale_to))) Begin Send CreateComObject of hoDate_on_sale_to End Get Create (RefClass(cComChilkatDtObj)) To hoDate_on_sale_to_gmt If (Not(IsComObjectCreated(hoDate_on_sale_to_gmt))) Begin Send CreateComObject of hoDate_on_sale_to_gmt End Move 0 To i Get ComSize Of hoJarrResp To iCount_i While (i < iCount_i) Get ComObjectAt Of hoJarrResp i To vJson If (IsComObject(vJson)) Begin Get Create (RefClass(cComChilkatJsonObject)) To hoJson Set pvComObject Of hoJson To vJson End Get ComIntOf Of hoJson "id" To iId Get ComStringOf Of hoJson "name" To sName Get ComStringOf Of hoJson "slug" To sSlug Get ComStringOf Of hoJson "permalink" To sPermalink Get pvComObject of hoDate_created to vDate_created Get ComDtOf Of hoJson "date_created" False vDate_created To iSuccess Get pvComObject of hoDate_created_gmt to vDate_created_gmt Get ComDtOf Of hoJson "date_created_gmt" False vDate_created_gmt To iSuccess Get pvComObject of hoDate_modified to vDate_modified Get ComDtOf Of hoJson "date_modified" False vDate_modified To iSuccess Get pvComObject of hoDate_modified_gmt to vDate_modified_gmt Get ComDtOf Of hoJson "date_modified_gmt" False vDate_modified_gmt To iSuccess Get ComStringOf Of hoJson "type" To sV_type Get ComStringOf Of hoJson "status" To sStatus Get ComBoolOf Of hoJson "featured" To iFeatured Get ComStringOf Of hoJson "catalog_visibility" To sCatalog_visibility Get ComStringOf Of hoJson "description" To sDescription Get ComStringOf Of hoJson "short_description" To sShort_description Get ComStringOf Of hoJson "sku" To sSku Get ComStringOf Of hoJson "price" To sPrice Get ComStringOf Of hoJson "regular_price" To sRegular_price Get ComStringOf Of hoJson "sale_price" To sSale_price Get pvComObject of hoDate_on_sale_from to vDate_on_sale_from Get ComDtOf Of hoJson "date_on_sale_from" False vDate_on_sale_from To iSuccess Get pvComObject of hoDate_on_sale_from_gmt to vDate_on_sale_from_gmt Get ComDtOf Of hoJson "date_on_sale_from_gmt" False vDate_on_sale_from_gmt To iSuccess Get pvComObject of hoDate_on_sale_to to vDate_on_sale_to Get ComDtOf Of hoJson "date_on_sale_to" False vDate_on_sale_to To iSuccess Get pvComObject of hoDate_on_sale_to_gmt to vDate_on_sale_to_gmt Get ComDtOf Of hoJson "date_on_sale_to_gmt" False vDate_on_sale_to_gmt To iSuccess Get ComStringOf Of hoJson "price_html" To sPrice_html Get ComBoolOf Of hoJson "on_sale" To iOn_sale Get ComBoolOf Of hoJson "purchasable" To iPurchasable Get ComIntOf Of hoJson "total_sales" To iTotal_sales Get ComBoolOf Of hoJson "virtual" To iV_virtual Get ComBoolOf Of hoJson "downloadable" To iDownloadable Get ComIntOf Of hoJson "download_limit" To iDownload_limit Get ComIntOf Of hoJson "download_expiry" To iDownload_expiry Get ComStringOf Of hoJson "external_url" To sExternal_url Get ComStringOf Of hoJson "button_text" To sButton_text Get ComStringOf Of hoJson "tax_status" To sTax_status Get ComStringOf Of hoJson "tax_class" To sTax_class Get ComBoolOf Of hoJson "manage_stock" To iManage_stock Get ComStringOf Of hoJson "stock_quantity" To sStock_quantity Get ComStringOf Of hoJson "stock_status" To sStock_status Get ComStringOf Of hoJson "backorders" To sBackorders Get ComBoolOf Of hoJson "backorders_allowed" To iBackorders_allowed Get ComBoolOf Of hoJson "backordered" To iBackordered Get ComBoolOf Of hoJson "sold_individually" To iSold_individually Get ComStringOf Of hoJson "weight" To sWeight Get ComStringOf Of hoJson "dimensions.length" To sDimensionsLength Get ComStringOf Of hoJson "dimensions.width" To sDimensionsWidth Get ComStringOf Of hoJson "dimensions.height" To sDimensionsHeight Get ComBoolOf Of hoJson "shipping_required" To iShipping_required Get ComBoolOf Of hoJson "shipping_taxable" To iShipping_taxable Get ComStringOf Of hoJson "shipping_class" To sShipping_class Get ComIntOf Of hoJson "shipping_class_id" To iShipping_class_id Get ComBoolOf Of hoJson "reviews_allowed" To iReviews_allowed Get ComStringOf Of hoJson "average_rating" To sAverage_rating Get ComIntOf Of hoJson "rating_count" To iRating_count Get ComIntOf Of hoJson "parent_id" To iParent_id Get ComStringOf Of hoJson "purchase_note" To sPurchase_note Get ComIntOf Of hoJson "menu_order" To iMenu_order Move 0 To j Get ComSizeOfArray Of hoJson "downloads" To iCount_j While (j < iCount_j) Set ComJ Of hoJson To j Move (j + 1) To j Loop Move 0 To j Get ComSizeOfArray Of hoJson "related_ids" To iCount_j While (j < iCount_j) Set ComJ Of hoJson To j Get ComIntOf Of hoJson "related_ids[j]" To iIntVal Move (j + 1) To j Loop Move 0 To j Get ComSizeOfArray Of hoJson "upsell_ids" To iCount_j While (j < iCount_j) Set ComJ Of hoJson To j Move (j + 1) To j Loop Move 0 To j Get ComSizeOfArray Of hoJson "cross_sell_ids" To iCount_j While (j < iCount_j) Set ComJ Of hoJson To j Move (j + 1) To j Loop Move 0 To j Get ComSizeOfArray Of hoJson "categories" To iCount_j While (j < iCount_j) Set ComJ Of hoJson To j Get ComIntOf Of hoJson "categories[j].id" To iId Get ComStringOf Of hoJson "categories[j].name" To sName Get ComStringOf Of hoJson "categories[j].slug" To sSlug Move (j + 1) To j Loop Move 0 To j Get ComSizeOfArray Of hoJson "tags" To iCount_j While (j < iCount_j) Set ComJ Of hoJson To j Move (j + 1) To j Loop Move 0 To j Get ComSizeOfArray Of hoJson "images" To iCount_j While (j < iCount_j) Set ComJ Of hoJson To j Get ComIntOf Of hoJson "images[j].id" To iId Get pvComObject of hoDate_created to vDate_created Get ComDtOf Of hoJson "images[j].date_created" False vDate_created To iSuccess Get pvComObject of hoDate_created_gmt to vDate_created_gmt Get ComDtOf Of hoJson "images[j].date_created_gmt" False vDate_created_gmt To iSuccess Get pvComObject of hoDate_modified to vDate_modified Get ComDtOf Of hoJson "images[j].date_modified" False vDate_modified To iSuccess Get pvComObject of hoDate_modified_gmt to vDate_modified_gmt Get ComDtOf Of hoJson "images[j].date_modified_gmt" False vDate_modified_gmt To iSuccess Get ComStringOf Of hoJson "images[j].src" To sSrc Get ComStringOf Of hoJson "images[j].name" To sName Get ComStringOf Of hoJson "images[j].alt" To sAlt Move (j + 1) To j Loop Move 0 To j Get ComSizeOfArray Of hoJson "attributes" To iCount_j While (j < iCount_j) Set ComJ Of hoJson To j Get ComIntOf Of hoJson "attributes[j].id" To iId Get ComStringOf Of hoJson "attributes[j].name" To sName Get ComIntOf Of hoJson "attributes[j].position" To iPosition Get ComBoolOf Of hoJson "attributes[j].visible" To iVisible Get ComBoolOf Of hoJson "attributes[j].variation" To iVariation Move 0 To k Get ComSizeOfArray Of hoJson "attributes[j].options" To iCount_k While (k < iCount_k) Set ComK Of hoJson To k Get ComStringOf Of hoJson "attributes[j].options[k]" To sStrVal Move (k + 1) To k Loop Move (j + 1) To j Loop Move 0 To j Get ComSizeOfArray Of hoJson "default_attributes" To iCount_j While (j < iCount_j) Set ComJ Of hoJson To j Get ComIntOf Of hoJson "default_attributes[j].id" To iId Get ComStringOf Of hoJson "default_attributes[j].name" To sName Get ComStringOf Of hoJson "default_attributes[j].option" To sV_option Move (j + 1) To j Loop Move 0 To j Get ComSizeOfArray Of hoJson "variations" To iCount_j While (j < iCount_j) Set ComJ Of hoJson To j Move (j + 1) To j Loop Move 0 To j Get ComSizeOfArray Of hoJson "grouped_products" To iCount_j While (j < iCount_j) Set ComJ Of hoJson To j Move (j + 1) To j Loop Move 0 To j Get ComSizeOfArray Of hoJson "meta_data" To iCount_j While (j < iCount_j) Set ComJ Of hoJson To j Move (j + 1) To j Loop Move 0 To j Get ComSizeOfArray Of hoJson "_links.self" To iCount_j While (j < iCount_j) Set ComJ Of hoJson To j Get ComStringOf Of hoJson "_links.self[j].href" To sHref Move (j + 1) To j Loop Move 0 To j Get ComSizeOfArray Of hoJson "_links.collection" To iCount_j While (j < iCount_j) Set ComJ Of hoJson To j Get ComStringOf Of hoJson "_links.collection[j].href" To sHref Move (j + 1) To j Loop Send Destroy of hoJson Move (i + 1) To i Loop End_Procedure |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.