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 Retrieve a ProductSee more WooCommerce ExamplesDemonstrates how to get the information for a product in JSON format. For more information, see https://woocommerce.github.io/woocommerce-rest-api-docs/#retrieve-a-product
Use ChilkatAx-win32.pkg Procedure Test Handle hoHttp Boolean iSuccess Variant vSbResponseBody Handle hoSbResponseBody Handle hoJResp 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 Integer iIntVal String sSrc String sAlt String sHref 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 iVirtual 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 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/794 \ // -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/794" vSbResponseBody To iSuccess If (iSuccess = False) Begin Get ComLastErrorText Of hoHttp To sTemp1 Showln sTemp1 Procedure_Return End Get Create (RefClass(cComChilkatJsonObject)) To hoJResp If (Not(IsComObjectCreated(hoJResp))) Begin Send CreateComObject of hoJResp End Get pvComObject of hoSbResponseBody to vSbResponseBody Get ComLoadSb Of hoJResp vSbResponseBody To iSuccess Set ComEmitCompact Of hoJResp To False Showln "Response Body:" Get ComEmit Of hoJResp 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": 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": [ // 53, // 40, // 56, // 479, // 99 // ], // "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": [ // ], // "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 Get ComIntOf Of hoJResp "id" To iId Get ComStringOf Of hoJResp "name" To sName Get ComStringOf Of hoJResp "slug" To sSlug Get ComStringOf Of hoJResp "permalink" To sPermalink Get pvComObject of hoDate_created to vDate_created Get ComDtOf Of hoJResp "date_created" False vDate_created To iSuccess Get pvComObject of hoDate_created_gmt to vDate_created_gmt Get ComDtOf Of hoJResp "date_created_gmt" False vDate_created_gmt To iSuccess Get pvComObject of hoDate_modified to vDate_modified Get ComDtOf Of hoJResp "date_modified" False vDate_modified To iSuccess Get pvComObject of hoDate_modified_gmt to vDate_modified_gmt Get ComDtOf Of hoJResp "date_modified_gmt" False vDate_modified_gmt To iSuccess Get ComStringOf Of hoJResp "type" To sV_type Get ComStringOf Of hoJResp "status" To sStatus Get ComBoolOf Of hoJResp "featured" To iFeatured Get ComStringOf Of hoJResp "catalog_visibility" To sCatalog_visibility Get ComStringOf Of hoJResp "description" To sDescription Get ComStringOf Of hoJResp "short_description" To sShort_description Get ComStringOf Of hoJResp "sku" To sSku Get ComStringOf Of hoJResp "price" To sPrice Get ComStringOf Of hoJResp "regular_price" To sRegular_price Get ComStringOf Of hoJResp "sale_price" To sSale_price Get pvComObject of hoDate_on_sale_from to vDate_on_sale_from Get ComDtOf Of hoJResp "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 hoJResp "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 hoJResp "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 hoJResp "date_on_sale_to_gmt" False vDate_on_sale_to_gmt To iSuccess Get ComStringOf Of hoJResp "price_html" To sPrice_html Get ComBoolOf Of hoJResp "on_sale" To iOn_sale Get ComBoolOf Of hoJResp "purchasable" To iPurchasable Get ComIntOf Of hoJResp "total_sales" To iTotal_sales Get ComBoolOf Of hoJResp "virtual" To iVirtual Get ComBoolOf Of hoJResp "downloadable" To iDownloadable Get ComIntOf Of hoJResp "download_limit" To iDownload_limit Get ComIntOf Of hoJResp "download_expiry" To iDownload_expiry Get ComStringOf Of hoJResp "external_url" To sExternal_url Get ComStringOf Of hoJResp "button_text" To sButton_text Get ComStringOf Of hoJResp "tax_status" To sTax_status Get ComStringOf Of hoJResp "tax_class" To sTax_class Get ComBoolOf Of hoJResp "manage_stock" To iManage_stock Get ComStringOf Of hoJResp "stock_quantity" To sStock_quantity Get ComStringOf Of hoJResp "stock_status" To sStock_status Get ComStringOf Of hoJResp "backorders" To sBackorders Get ComBoolOf Of hoJResp "backorders_allowed" To iBackorders_allowed Get ComBoolOf Of hoJResp "backordered" To iBackordered Get ComBoolOf Of hoJResp "sold_individually" To iSold_individually Get ComStringOf Of hoJResp "weight" To sWeight Get ComStringOf Of hoJResp "dimensions.length" To sDimensionsLength Get ComStringOf Of hoJResp "dimensions.width" To sDimensionsWidth Get ComStringOf Of hoJResp "dimensions.height" To sDimensionsHeight Get ComBoolOf Of hoJResp "shipping_required" To iShipping_required Get ComBoolOf Of hoJResp "shipping_taxable" To iShipping_taxable Get ComStringOf Of hoJResp "shipping_class" To sShipping_class Get ComIntOf Of hoJResp "shipping_class_id" To iShipping_class_id Get ComBoolOf Of hoJResp "reviews_allowed" To iReviews_allowed Get ComStringOf Of hoJResp "average_rating" To sAverage_rating Get ComIntOf Of hoJResp "rating_count" To iRating_count Get ComIntOf Of hoJResp "parent_id" To iParent_id Get ComStringOf Of hoJResp "purchase_note" To sPurchase_note Get ComIntOf Of hoJResp "menu_order" To iMenu_order Move 0 To i Get ComSizeOfArray Of hoJResp "downloads" To iCount_i While (i < iCount_i) Set ComI Of hoJResp To i Move (i + 1) To i Loop Move 0 To i Get ComSizeOfArray Of hoJResp "related_ids" To iCount_i While (i < iCount_i) Set ComI Of hoJResp To i Get ComIntOf Of hoJResp "related_ids[i]" To iIntVal Move (i + 1) To i Loop Move 0 To i Get ComSizeOfArray Of hoJResp "upsell_ids" To iCount_i While (i < iCount_i) Set ComI Of hoJResp To i Move (i + 1) To i Loop Move 0 To i Get ComSizeOfArray Of hoJResp "cross_sell_ids" To iCount_i While (i < iCount_i) Set ComI Of hoJResp To i Move (i + 1) To i Loop Move 0 To i Get ComSizeOfArray Of hoJResp "categories" To iCount_i While (i < iCount_i) Set ComI Of hoJResp To i Get ComIntOf Of hoJResp "categories[i].id" To iId Get ComStringOf Of hoJResp "categories[i].name" To sName Get ComStringOf Of hoJResp "categories[i].slug" To sSlug Move (i + 1) To i Loop Move 0 To i Get ComSizeOfArray Of hoJResp "tags" To iCount_i While (i < iCount_i) Set ComI Of hoJResp To i Move (i + 1) To i Loop Move 0 To i Get ComSizeOfArray Of hoJResp "images" To iCount_i While (i < iCount_i) Set ComI Of hoJResp To i Get ComIntOf Of hoJResp "images[i].id" To iId Get pvComObject of hoDate_created to vDate_created Get ComDtOf Of hoJResp "images[i].date_created" False vDate_created To iSuccess Get pvComObject of hoDate_created_gmt to vDate_created_gmt Get ComDtOf Of hoJResp "images[i].date_created_gmt" False vDate_created_gmt To iSuccess Get pvComObject of hoDate_modified to vDate_modified Get ComDtOf Of hoJResp "images[i].date_modified" False vDate_modified To iSuccess Get pvComObject of hoDate_modified_gmt to vDate_modified_gmt Get ComDtOf Of hoJResp "images[i].date_modified_gmt" False vDate_modified_gmt To iSuccess Get ComStringOf Of hoJResp "images[i].src" To sSrc Get ComStringOf Of hoJResp "images[i].name" To sName Get ComStringOf Of hoJResp "images[i].alt" To sAlt Move (i + 1) To i Loop Move 0 To i Get ComSizeOfArray Of hoJResp "attributes" To iCount_i While (i < iCount_i) Set ComI Of hoJResp To i Move (i + 1) To i Loop Move 0 To i Get ComSizeOfArray Of hoJResp "default_attributes" To iCount_i While (i < iCount_i) Set ComI Of hoJResp To i Move (i + 1) To i Loop Move 0 To i Get ComSizeOfArray Of hoJResp "variations" To iCount_i While (i < iCount_i) Set ComI Of hoJResp To i Move (i + 1) To i Loop Move 0 To i Get ComSizeOfArray Of hoJResp "grouped_products" To iCount_i While (i < iCount_i) Set ComI Of hoJResp To i Move (i + 1) To i Loop Move 0 To i Get ComSizeOfArray Of hoJResp "meta_data" To iCount_i While (i < iCount_i) Set ComI Of hoJResp To i Move (i + 1) To i Loop Move 0 To i Get ComSizeOfArray Of hoJResp "_links.self" To iCount_i While (i < iCount_i) Set ComI Of hoJResp To i Get ComStringOf Of hoJResp "_links.self[i].href" To sHref Move (i + 1) To i Loop Move 0 To i Get ComSizeOfArray Of hoJResp "_links.collection" To iCount_i While (i < iCount_i) Set ComI Of hoJResp To i Get ComStringOf Of hoJResp "_links.collection[i].href" To sHref Move (i + 1) To i Loop End_Procedure |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.