Chilkat Examples

ChilkatHOME.NET Core C#Android™AutoItCC#C++Chilkat2-PythonCkPythonClassic ASPDataFlexDelphi ActiveXDelphi DLLGoJavaLianjaMono C#Node.jsObjective-CPHP ActiveXPHP ExtensionPerlPowerBuilderPowerShellPureBasicRubySQL ServerSwift 2Swift 3,4,5...TclUnicode CUnicode C++VB.NETVBScriptVisual Basic 6.0Visual FoxProXojo Plugin

Unicode C++ Web API Examples

Primary Categories

ABN AMRO
AWS Secrets Manager
AWS Security Token Service
AWS Translate
Activix CRM
Adyen
Alibaba Cloud OSS
Amazon Cognito
Amazon DynamoDB
Amazon MWS
Amazon Pay
Amazon Rekognition
Amazon SP-API
Amazon Voice ID
Aruba Fatturazione
Azure Maps
Azure Monitor
Azure OAuth2
Azure Storage Accounts
Backblaze S3
Banco Inter
Belgian eHealth Platform
Bitfinex v2 REST
Bluzone
BrickLink
Bunny CDN
CallRail
CardConnect
Cerved
ClickBank
Clickatell
Cloudfare
Constant Contact
DocuSign
Duo Auth MFA
ETrade
Ecwid
Egypt ITIDA
Egypt eReceipt
Etsy
Facebook
Faire
Frame.io
GeoOp
GetHarvest
Global Payments
Google People
Google Search Console
Google Translate
Hungary NAV Invoicing
IBM Text to Speech
Ibanity
IntakeQ
Jira
Lightspeed
MYOB
Magento
Mailgun
Mastercard

MedTunnel
MercadoLibre
MessageMedia
Microsoft Calendar
Microsoft Group
Microsoft Tasks and Plans
Microsoft Teams
Moody's
Okta OAuth/OIDC
OneLogin OIDC
OneNote
OpenAI ChatGPT
PRODA
PayPal
Paynow.pl
Peoplevox
Populi
QuickBooks
Rabobank
Refinitiv
Royal Mail OBA
SCiS Schools Catalogue
SII Chile
SMSAPI
SOAP finkok.com
SendGrid
Shippo
Shopify
Shopware
Shopware 6
SimpleTexting
Square
Stripe
SugarCRM
TicketBAI
Trello
Twilio
Twitter API v2
Twitter v1
UPS
UniPin
VoiceBase
Vonage
WaTrend
Walmart v3
Wasabi
WhatsApp
WiX
WooCommerce
WordPress
Xero
Yahoo Mail
Yapily
Yousign
ZATCA
Zendesk
Zoom
_Miscellaneous_
eBay
effectconnect
hacienda.go.cr

 

 

 

(Unicode C++) Walmart - Get Inventory for an Item

Demonstrates how to get inventory for an item and parse the result.

Chilkat C/C++ Library Downloads

MS Visual C/C++

Linux/CentOS C/C++

Alpine Linux C/C++

MAC OS X C/C++

armhf/aarch64 C/C++

C++ Builder

iOS C/C++

Android C/C++

Solaris C/C++

MinGW C/C++

#include <CkStringBuilderW.h>
#include <CkAuthUtilW.h>
#include <CkJsonObjectW.h>
#include <CkHttpW.h>
#include <CkXmlW.h>

void ChilkatSample(void)
    {
    // ---------------------------------------------------------------------------------------------------------
    // Note: This example is deprecated.  The Walmart API no longer uses the Signature method of authenticating.
    // Walmart now uses OAuth2.  
    // ---------------------------------------------------------------------------------------------------------

    // This example requires the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    // Sends the following GET request:
    // GET https://marketplace.walmartapis.com/v2/inventory?sku={SKU}

    CkStringBuilderW sbUrl;
    bool success = sbUrl.Append(L"https://marketplace.walmartapis.com/v2/inventory?sku={SKU}");
    int numReplaced = sbUrl.Replace(L"{SKU}",L"HOPP~904~51041");

    const wchar_t *requestMethod = L"GET";

    // First we need to generate a signature for our request.
    // The signature needs to be re-generated for each new Walmart HTTP request.
    CkAuthUtilW authUtil;

    const wchar_t *wmConsumerId = L"WALMART_CONSUMER_ID";
    const wchar_t *wmPrivateKey = L"WALMART_PRIVATE_KEY";
    const wchar_t *jsonStr = authUtil.walmartSignature(sbUrl.getAsString(),wmConsumerId,wmPrivateKey,requestMethod);
    if (authUtil.get_LastMethodSuccess() != true) {
        wprintf(L"%s\n",authUtil.lastErrorText());
        return;
    }

    // The JSON returned by WalmartSignature contains the values to be used in the following
    // header fields: WM_SEC.AUTH_SIGNATURE, WM_SEC.TIMESTAMP, and WM_QOS.CORRELATION_ID
    CkJsonObjectW json;
    json.Load(jsonStr);

    CkHttpW http;
    http.SetRequestHeader(L"WM_SVC.NAME",L"Walmart Marketplace");
    http.SetRequestHeader(L"WM_QOS.CORRELATION_ID",json.stringOf(L"correlation_id"));
    http.SetRequestHeader(L"WM_SEC.TIMESTAMP",json.stringOf(L"timestamp"));
    http.SetRequestHeader(L"WM_SEC.AUTH_SIGNATURE",json.stringOf(L"signature"));
    http.SetRequestHeader(L"WM_CONSUMER.ID",wmConsumerId);
    http.put_Accept(L"application/xml");

    // Note: Do not explicitly set the "Host" header.  Chilkat will set it automatically.

    const wchar_t *xmlStr = http.quickGetStr(sbUrl.getAsString());
    if (http.get_LastMethodSuccess() != true) {
        wprintf(L"%s\n",http.lastErrorText());
        return;
    }

    CkXmlW xml;
    xml.LoadXml(xmlStr);

    // A successful response should have a 200 response status
    if (http.get_LastStatus() != 200) {
        wprintf(L"%s\n",xml.getXml());
        wprintf(L"Response Status Code: %d\n",http.get_LastStatus());
        wprintf(L"Failed.\n");
        return;
    }

    // A sample XML response is shown below..
    wprintf(L"%s\n",xml.getXml());
    wprintf(L"--\n");

    // To get the quantity:
    int quantity = xml.GetChildIntValue(L"quantity|amount");
    wprintf(L"quantity = %d\n",quantity);

    // ---------------------------------------
    // Sample XML response
    // ---------------------------------------

    // <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
    // <inventory xmlns="http://walmart.com/">
    //     <sku>HOPP~904~51041</sku>
    //     <quantity>
    //         <unit>EACH</unit>
    //         <amount>234</amount>
    //     </quantity>
    //     <fulfillmentLagTime>5</fulfillmentLagTime>
    // </inventory>
    }

 

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