Chilkat Examples

ChilkatHOMEAndroid™Classic ASPCC++C#Mono C#.NET Core C#C# UWP/WinRTDataFlexDelphi ActiveXDelphi DLLVisual FoxProJavaLianjaMFCObjective-CPerlPHP ActiveXPHP ExtensionPowerBuilderPowerShellPureBasicCkPythonChilkat2-PythonRubySQL ServerSwift 2Swift 3,4,5...TclUnicode CUnicode C++Visual Basic 6.0VB.NETVB.NET UWP/WinRTVBScriptXojo PluginNode.jsExcelGo

Java Web API Examples

Primary Categories

ABN AMRO
AWS Translate
Activix CRM
Adyen
Amazon DynamoDB
Amazon MWS
Aruba Fatturazione
Azure Maps
Azure Monitor
Azure OAuth2
Azure Storage Accounts
Bitfinex v2 REST
Bluzone
CallRail
CardConnect
ClickBank
Clickatell
Cloudfare
Constant Contact
DocuSign
ETrade
Etsy
Facebook
Frame.io
GeoOp
GetHarvest
Global Payments
Google People
Google Search Console
Hungary NAV Invoicing
IBM Text to Speech
Jira
Lightspeed
MYOB

Magento
MercadoLibre
Microsoft Calendar
Microsoft Group
Microsoft Tasks and Plans
Microsoft Teams
Okta OAuth/OIDC
OneLogin OIDC
OneNote
PayPal
Peoplevox
Populi
QuickBooks
Rabobank
SMSAPI
SOAP finkok.com
Shippo
Shopify
SimpleTexting
Square
Stripe
SugarCRM
Trello
Twilio
Twitter
VoiceBase
Vonage
Walmart
Walmart v3
WhatsApp
WiX
WooCommerce
Xero
Yousign
_Miscellaneous_
eBay
effectconnect

 

 

 

(Java) WooCommerce List All Products

Gets WooCommerce product information in JSON format.

For more information, see https://woocommerce.github.io/woocommerce-rest-api-docs/#list-all-products

Chilkat Java Downloads

Java Libs for Windows, Linux, Alpine Linux,
MAC OS X, Solaris, FreeBSD, OpenBSD,
Raspberry Pi and other single board computers

Java Libs for Android

import com.chilkatsoft.*;

public class ChilkatExample {

  static {
    try {
        System.loadLibrary("chilkat");
    } catch (UnsatisfiedLinkError e) {
      System.err.println("Native code library failed to load.\n" + e);
      System.exit(1);
    }
  }

  public static void main(String argv[])
  {
    // This example assumes the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    CkHttp http = new CkHttp();
    boolean success;

    // 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

    http.put_BasicAuth(true);
    http.put_Login("consumer_key");
    http.put_Password("consumer_secret");

    CkStringBuilder sbResponseBody = new CkStringBuilder();
    success = http.QuickGetSb("https://example.com/wp-json/wc/v3/products",sbResponseBody);
    if (success == false) {
        System.out.println(http.lastErrorText());
        return;
        }

    CkJsonArray jarrResp = new CkJsonArray();
    jarrResp.LoadSb(sbResponseBody);
    jarrResp.put_EmitCompact(false);

    System.out.println("Response Body:");
    System.out.println(jarrResp.emit());

    int respStatusCode = http.get_LastStatus();
    System.out.println("Response Status Code = " + respStatusCode);
    if (respStatusCode >= 400) {
        System.out.println("Response Header:");
        System.out.println(http.lastHeader());
        System.out.println("Failed.");
        return;
        }

    // 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\">&#36;</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

    CkDtObj date_created = new CkDtObj();
    CkDtObj date_created_gmt = new CkDtObj();
    CkDtObj date_modified = new CkDtObj();
    CkDtObj date_modified_gmt = new CkDtObj();
    CkDtObj date_on_sale_from = new CkDtObj();
    CkDtObj date_on_sale_from_gmt = new CkDtObj();
    CkDtObj date_on_sale_to = new CkDtObj();
    CkDtObj date_on_sale_to_gmt = new CkDtObj();
    CkJsonObject json;
    int id;
    String name;
    String slug;
    String permalink;
    String v_type;
    String status;
    boolean featured;
    String catalog_visibility;
    String description;
    String short_description;
    String sku;
    String price;
    String regular_price;
    String sale_price;
    String price_html;
    boolean on_sale;
    boolean purchasable;
    int total_sales;
    boolean v_virtual;
    boolean downloadable;
    int download_limit;
    int download_expiry;
    String external_url;
    String button_text;
    String tax_status;
    String tax_class;
    boolean manage_stock;
    String stock_quantity;
    String stock_status;
    String backorders;
    boolean backorders_allowed;
    boolean backordered;
    boolean sold_individually;
    String weight;
    String dimensionsLength;
    String dimensionsWidth;
    String dimensionsHeight;
    boolean shipping_required;
    boolean shipping_taxable;
    String shipping_class;
    int shipping_class_id;
    boolean reviews_allowed;
    String average_rating;
    int rating_count;
    int parent_id;
    String purchase_note;
    int menu_order;
    int j;
    int count_j;
    int intVal;
    String src;
    String alt;
    int position;
    boolean visible;
    boolean variation;
    int k;
    int count_k;
    String strVal;
    String v_option;
    String href;

    int i = 0;
    int count_i = jarrResp.get_Size();
    while (i < count_i) {
        json = jarrResp.ObjectAt(i);
        id = json.IntOf("id");
        name = json.stringOf("name");
        slug = json.stringOf("slug");
        permalink = json.stringOf("permalink");
        json.DtOf("date_created",false,date_created);
        json.DtOf("date_created_gmt",false,date_created_gmt);
        json.DtOf("date_modified",false,date_modified);
        json.DtOf("date_modified_gmt",false,date_modified_gmt);
        v_type = json.stringOf("type");
        status = json.stringOf("status");
        featured = json.BoolOf("featured");
        catalog_visibility = json.stringOf("catalog_visibility");
        description = json.stringOf("description");
        short_description = json.stringOf("short_description");
        sku = json.stringOf("sku");
        price = json.stringOf("price");
        regular_price = json.stringOf("regular_price");
        sale_price = json.stringOf("sale_price");
        json.DtOf("date_on_sale_from",false,date_on_sale_from);
        json.DtOf("date_on_sale_from_gmt",false,date_on_sale_from_gmt);
        json.DtOf("date_on_sale_to",false,date_on_sale_to);
        json.DtOf("date_on_sale_to_gmt",false,date_on_sale_to_gmt);
        price_html = json.stringOf("price_html");
        on_sale = json.BoolOf("on_sale");
        purchasable = json.BoolOf("purchasable");
        total_sales = json.IntOf("total_sales");
        v_virtual = json.BoolOf("virtual");
        downloadable = json.BoolOf("downloadable");
        download_limit = json.IntOf("download_limit");
        download_expiry = json.IntOf("download_expiry");
        external_url = json.stringOf("external_url");
        button_text = json.stringOf("button_text");
        tax_status = json.stringOf("tax_status");
        tax_class = json.stringOf("tax_class");
        manage_stock = json.BoolOf("manage_stock");
        stock_quantity = json.stringOf("stock_quantity");
        stock_status = json.stringOf("stock_status");
        backorders = json.stringOf("backorders");
        backorders_allowed = json.BoolOf("backorders_allowed");
        backordered = json.BoolOf("backordered");
        sold_individually = json.BoolOf("sold_individually");
        weight = json.stringOf("weight");
        dimensionsLength = json.stringOf("dimensions.length");
        dimensionsWidth = json.stringOf("dimensions.width");
        dimensionsHeight = json.stringOf("dimensions.height");
        shipping_required = json.BoolOf("shipping_required");
        shipping_taxable = json.BoolOf("shipping_taxable");
        shipping_class = json.stringOf("shipping_class");
        shipping_class_id = json.IntOf("shipping_class_id");
        reviews_allowed = json.BoolOf("reviews_allowed");
        average_rating = json.stringOf("average_rating");
        rating_count = json.IntOf("rating_count");
        parent_id = json.IntOf("parent_id");
        purchase_note = json.stringOf("purchase_note");
        menu_order = json.IntOf("menu_order");
        j = 0;
        count_j = json.SizeOfArray("downloads");
        while (j < count_j) {
            json.put_J(j);
            j = j+1;
            }

        j = 0;
        count_j = json.SizeOfArray("related_ids");
        while (j < count_j) {
            json.put_J(j);
            intVal = json.IntOf("related_ids[j]");
            j = j+1;
            }

        j = 0;
        count_j = json.SizeOfArray("upsell_ids");
        while (j < count_j) {
            json.put_J(j);
            j = j+1;
            }

        j = 0;
        count_j = json.SizeOfArray("cross_sell_ids");
        while (j < count_j) {
            json.put_J(j);
            j = j+1;
            }

        j = 0;
        count_j = json.SizeOfArray("categories");
        while (j < count_j) {
            json.put_J(j);
            id = json.IntOf("categories[j].id");
            name = json.stringOf("categories[j].name");
            slug = json.stringOf("categories[j].slug");
            j = j+1;
            }

        j = 0;
        count_j = json.SizeOfArray("tags");
        while (j < count_j) {
            json.put_J(j);
            j = j+1;
            }

        j = 0;
        count_j = json.SizeOfArray("images");
        while (j < count_j) {
            json.put_J(j);
            id = json.IntOf("images[j].id");
            json.DtOf("images[j].date_created",false,date_created);
            json.DtOf("images[j].date_created_gmt",false,date_created_gmt);
            json.DtOf("images[j].date_modified",false,date_modified);
            json.DtOf("images[j].date_modified_gmt",false,date_modified_gmt);
            src = json.stringOf("images[j].src");
            name = json.stringOf("images[j].name");
            alt = json.stringOf("images[j].alt");
            j = j+1;
            }

        j = 0;
        count_j = json.SizeOfArray("attributes");
        while (j < count_j) {
            json.put_J(j);
            id = json.IntOf("attributes[j].id");
            name = json.stringOf("attributes[j].name");
            position = json.IntOf("attributes[j].position");
            visible = json.BoolOf("attributes[j].visible");
            variation = json.BoolOf("attributes[j].variation");
            k = 0;
            count_k = json.SizeOfArray("attributes[j].options");
            while (k < count_k) {
                json.put_K(k);
                strVal = json.stringOf("attributes[j].options[k]");
                k = k+1;
                }

            j = j+1;
            }

        j = 0;
        count_j = json.SizeOfArray("default_attributes");
        while (j < count_j) {
            json.put_J(j);
            id = json.IntOf("default_attributes[j].id");
            name = json.stringOf("default_attributes[j].name");
            v_option = json.stringOf("default_attributes[j].option");
            j = j+1;
            }

        j = 0;
        count_j = json.SizeOfArray("variations");
        while (j < count_j) {
            json.put_J(j);
            j = j+1;
            }

        j = 0;
        count_j = json.SizeOfArray("grouped_products");
        while (j < count_j) {
            json.put_J(j);
            j = j+1;
            }

        j = 0;
        count_j = json.SizeOfArray("meta_data");
        while (j < count_j) {
            json.put_J(j);
            j = j+1;
            }

        j = 0;
        count_j = json.SizeOfArray("_links.self");
        while (j < count_j) {
            json.put_J(j);
            href = json.stringOf("_links.self[j].href");
            j = j+1;
            }

        j = 0;
        count_j = json.SizeOfArray("_links.collection");
        while (j < count_j) {
            json.put_J(j);
            href = json.stringOf("_links.collection[j].href");
            j = j+1;
            }

        i = i+1;
        }
  }
}

 

© 2000-2020 Chilkat Software, Inc. All Rights Reserved.