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
(Unicode C) Shopware List ArticlesSee more Shopware ExamplesThis example shows you how to obtain information about a Shopware product list. With the optional limit parameter, it's possible to specify how many products you wish the API call to return. For more information, see https://developers.shopware.com/developers-guide/rest-api/examples/article/
#include <C_CkHttpW.h> #include <C_CkStringBuilderW.h> #include <C_CkJsonObjectW.h> void ChilkatSample(void) { HCkHttpW http; HCkStringBuilderW sbResponseBody; BOOL success; HCkJsonObjectW jResp; int id; int mainDetailId; int supplierId; int taxId; int priceGroupId; const wchar_t *filterGroupId; const wchar_t *configuratorSetId; const wchar_t *name; const wchar_t *description; const wchar_t *descriptionLong; const wchar_t *added; BOOL active; int pseudoSales; BOOL highlight; const wchar_t *keywords; const wchar_t *metaTitle; const wchar_t *changed; BOOL priceGroupActive; BOOL lastStock; int crossBundleLook; BOOL notification; const wchar_t *template; int mode; const wchar_t *availableFrom; const wchar_t *availableTo; int mainDetailArticleId; int mainDetailUnitId; const wchar_t *mainDetailNumber; const wchar_t *mainDetailSupplierNumber; int mainDetailKind; const wchar_t *mainDetailAdditionalText; BOOL mainDetailActive; int mainDetailInStock; const wchar_t *mainDetailStockMin; BOOL mainDetailLastStock; const wchar_t *mainDetailWeight; const wchar_t *mainDetailWidth; const wchar_t *mainDetailLen; const wchar_t *mainDetailHeight; const wchar_t *mainDetailEan; const wchar_t *mainDetailPurchasePrice; int mainDetailPosition; int mainDetailMinPurchase; int mainDetailPurchaseSteps; int mainDetailMaxPurchase; const wchar_t *mainDetailPurchaseUnit; const wchar_t *mainDetailReferenceUnit; const wchar_t *mainDetailPackUnit; BOOL mainDetailShippingFree; const wchar_t *mainDetailReleaseDate; const wchar_t *mainDetailShippingTime; int mainDetailAttributeId; int mainDetailAttributeArticleDetailId; const wchar_t *mainDetailAttributeAttr1; const wchar_t *mainDetailAttributeAttr2; const wchar_t *mainDetailAttributeAttr3; const wchar_t *mainDetailAttributeAttr4; const wchar_t *mainDetailAttributeAttr5; const wchar_t *mainDetailAttributeAttr6; const wchar_t *mainDetailAttributeAttr7; const wchar_t *mainDetailAttributeAttr8; const wchar_t *mainDetailAttributeAttr9; const wchar_t *mainDetailAttributeAttr10; const wchar_t *mainDetailAttributeAttr11; const wchar_t *mainDetailAttributeAttr12; const wchar_t *mainDetailAttributeAttr13; const wchar_t *mainDetailAttributeAttr14; const wchar_t *mainDetailAttributeAttr15; const wchar_t *mainDetailAttributeAttr16; const wchar_t *mainDetailAttributeAttr17; const wchar_t *mainDetailAttributeAttr18; const wchar_t *mainDetailAttributeAttr19; const wchar_t *mainDetailAttributeAttr20; const wchar_t *mainDetailAttributeApostroph; int total; BOOL success; int i; int count_i; // This example assumes the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. http = CkHttpW_Create(); CkHttpW_putLogin(http,L"api_username"); CkHttpW_putPassword(http,L"api_key"); CkHttpW_putBasicAuth(http,TRUE); sbResponseBody = CkStringBuilderW_Create(); success = CkHttpW_QuickGetSb(http,L"https://my-shopware-shop.com/api/articles?limit=2",sbResponseBody); if (success == FALSE) { wprintf(L"%s\n",CkHttpW_lastErrorText(http)); CkHttpW_Dispose(http); CkStringBuilderW_Dispose(sbResponseBody); return; } jResp = CkJsonObjectW_Create(); CkJsonObjectW_LoadSb(jResp,sbResponseBody); CkJsonObjectW_putEmitCompact(jResp,FALSE); wprintf(L"Response Body:\n"); wprintf(L"%s\n",CkJsonObjectW_emit(jResp)); // Sample JSON response: // (Sample code for parsing the JSON response is shown below) // { // "data": [ // { // "id": 8283, // "mainDetailId": 11398, // "supplierId": 28, // "taxId": 1, // "priceGroupId": 1, // "filterGroupId": null, // "configuratorSetId": null, // "name": "TERRA PC-GAMER 8000 iQ9650 VU - \u00e5\u00a0 \u00c7 Produktmer", // "description": "TERRA PC-GAMER 8000 iQ9650 VU - \u00e5\u00a0 \u00c7 Produktmer", // "descriptionLong": "...", // "added": "2000-01-01T00:00:00+0100", // "active": true, // "pseudoSales": 0, // "highlight": false, // "keywords": null, // "metaTitle": "TERRA PC-GAMER 8000 iQ9650 VU - \u00e5\u00a0 \u00c7 Produktmer", // "changed": "2021-02-21T18:20:39+0100", // "priceGroupActive": false, // "lastStock": false, // "crossBundleLook": 0, // "notification": true, // "template": "", // "mode": 0, // "availableFrom": null, // "availableTo": null, // "mainDetail": { // "id": 11398, // "articleId": 8283, // "unitId": 9, // "number": "WT-1000104", // "supplierNumber": "", // "kind": 1, // "additionalText": "", // "active": true, // "inStock": 28, // "stockMin": null, // "lastStock": false, // "weight": "0.000", // "width": null, // "len": null, // "height": null, // "ean": "4039407005390", // "purchasePrice": "0", // "position": 1, // "minPurchase": 1, // "purchaseSteps": 0, // "maxPurchase": 0, // "purchaseUnit": "0.0000", // "referenceUnit": "1.000", // "packUnit": "Stk", // "shippingFree": false, // "releaseDate": null, // "shippingTime": "20", // "attribute": { // "id": 11271, // "articleDetailId": 11398, // "attr1": null, // "attr2": null, // "attr3": null, // "attr4": null, // "attr5": null, // "attr6": null, // "attr7": null, // "attr8": null, // "attr9": null, // "attr10": null, // "attr11": "Attributfeld 11 deutsch", // "attr12": null, // "attr13": null, // "attr14": "Wortmann - 80061", // "attr15": null, // "attr16": null, // "attr17": "21.02.2021 18:36:46", // "attr18": null, // "attr19": "21.02.2021 18:36:46", // "attr20": "0,00", // "apostroph": "" // } // } // }, // { // "id": 8284, // "mainDetailId": 11399, // "supplierId": 28, // "taxId": 1, // "priceGroupId": 1, // "filterGroupId": null, // "configuratorSetId": null, // "name": "TERRA PC-GAMER 9000 iE5420 VU\rProduktmer", // "description": "TERRA PC-GAMER 9000 iE5420 VU\rProduktmer", // "descriptionLong": "...", // "added": "2000-01-01T00:00:00+0100", // "active": true, // "pseudoSales": 0, // "highlight": false, // "keywords": null, // "metaTitle": "TERRA PC-GAMER 9000 iE5420 VU\rProduktmer", // "changed": "2021-02-21T18:20:35+0100", // "priceGroupActive": false, // "lastStock": true, // "crossBundleLook": 0, // "notification": true, // "template": "", // "mode": 0, // "availableFrom": null, // "availableTo": null, // "mainDetail": { // "id": 11399, // "articleId": 8284, // "unitId": 9, // "number": "WT-1000105", // "supplierNumber": "", // "kind": 1, // "additionalText": "", // "active": true, // "inStock": 0, // "stockMin": null, // "lastStock": true, // "weight": "0.000", // "width": null, // "len": null, // "height": null, // "ean": "4039407006137", // "purchasePrice": "0", // "position": 1, // "minPurchase": 1, // "purchaseSteps": 0, // "maxPurchase": 0, // "purchaseUnit": "0.0000", // "referenceUnit": "1.000", // "packUnit": "Stk", // "shippingFree": false, // "releaseDate": null, // "shippingTime": "20", // "attribute": { // "id": 11272, // "articleDetailId": 11399, // "attr1": null, // "attr2": null, // "attr3": null, // "attr4": null, // "attr5": null, // "attr6": null, // "attr7": null, // "attr8": null, // "attr9": null, // "attr10": null, // "attr11": "Attributfeld 11 deutsch", // "attr12": null, // "attr13": null, // "attr14": "Wortmann - 80061", // "attr15": null, // "attr16": null, // "attr17": "21.02.2021 18:36:50", // "attr18": null, // "attr19": "21.02.2021 18:36:50", // "attr20": "0,00", // "apostroph": "" // } // } // } // ], // "total": 9, // "success": true // } // Sample code for parsing the JSON response... // Use the following online tool to generate parsing code from sample JSON: // Generate Parsing Code from JSON // Chilkat functions returning "const char *" return a pointer to temporary internal memory owned and managed by Chilkat. // See this example explaining how this memory should be used: const char * functions. total = CkJsonObjectW_IntOf(jResp,L"total"); success = CkJsonObjectW_BoolOf(jResp,L"success"); i = 0; count_i = CkJsonObjectW_SizeOfArray(jResp,L"data"); while (i < count_i) { CkJsonObjectW_putI(jResp,i); id = CkJsonObjectW_IntOf(jResp,L"data[i].id"); mainDetailId = CkJsonObjectW_IntOf(jResp,L"data[i].mainDetailId"); supplierId = CkJsonObjectW_IntOf(jResp,L"data[i].supplierId"); taxId = CkJsonObjectW_IntOf(jResp,L"data[i].taxId"); priceGroupId = CkJsonObjectW_IntOf(jResp,L"data[i].priceGroupId"); filterGroupId = CkJsonObjectW_stringOf(jResp,L"data[i].filterGroupId"); configuratorSetId = CkJsonObjectW_stringOf(jResp,L"data[i].configuratorSetId"); name = CkJsonObjectW_stringOf(jResp,L"data[i].name"); description = CkJsonObjectW_stringOf(jResp,L"data[i].description"); descriptionLong = CkJsonObjectW_stringOf(jResp,L"data[i].descriptionLong"); added = CkJsonObjectW_stringOf(jResp,L"data[i].added"); active = CkJsonObjectW_BoolOf(jResp,L"data[i].active"); pseudoSales = CkJsonObjectW_IntOf(jResp,L"data[i].pseudoSales"); highlight = CkJsonObjectW_BoolOf(jResp,L"data[i].highlight"); keywords = CkJsonObjectW_stringOf(jResp,L"data[i].keywords"); metaTitle = CkJsonObjectW_stringOf(jResp,L"data[i].metaTitle"); changed = CkJsonObjectW_stringOf(jResp,L"data[i].changed"); priceGroupActive = CkJsonObjectW_BoolOf(jResp,L"data[i].priceGroupActive"); lastStock = CkJsonObjectW_BoolOf(jResp,L"data[i].lastStock"); crossBundleLook = CkJsonObjectW_IntOf(jResp,L"data[i].crossBundleLook"); notification = CkJsonObjectW_BoolOf(jResp,L"data[i].notification"); template = CkJsonObjectW_stringOf(jResp,L"data[i].template"); mode = CkJsonObjectW_IntOf(jResp,L"data[i].mode"); availableFrom = CkJsonObjectW_stringOf(jResp,L"data[i].availableFrom"); availableTo = CkJsonObjectW_stringOf(jResp,L"data[i].availableTo"); mainDetailId = CkJsonObjectW_IntOf(jResp,L"data[i].mainDetail.id"); mainDetailArticleId = CkJsonObjectW_IntOf(jResp,L"data[i].mainDetail.articleId"); mainDetailUnitId = CkJsonObjectW_IntOf(jResp,L"data[i].mainDetail.unitId"); mainDetailNumber = CkJsonObjectW_stringOf(jResp,L"data[i].mainDetail.number"); mainDetailSupplierNumber = CkJsonObjectW_stringOf(jResp,L"data[i].mainDetail.supplierNumber"); mainDetailKind = CkJsonObjectW_IntOf(jResp,L"data[i].mainDetail.kind"); mainDetailAdditionalText = CkJsonObjectW_stringOf(jResp,L"data[i].mainDetail.additionalText"); mainDetailActive = CkJsonObjectW_BoolOf(jResp,L"data[i].mainDetail.active"); mainDetailInStock = CkJsonObjectW_IntOf(jResp,L"data[i].mainDetail.inStock"); mainDetailStockMin = CkJsonObjectW_stringOf(jResp,L"data[i].mainDetail.stockMin"); mainDetailLastStock = CkJsonObjectW_BoolOf(jResp,L"data[i].mainDetail.lastStock"); mainDetailWeight = CkJsonObjectW_stringOf(jResp,L"data[i].mainDetail.weight"); mainDetailWidth = CkJsonObjectW_stringOf(jResp,L"data[i].mainDetail.width"); mainDetailLen = CkJsonObjectW_stringOf(jResp,L"data[i].mainDetail.len"); mainDetailHeight = CkJsonObjectW_stringOf(jResp,L"data[i].mainDetail.height"); mainDetailEan = CkJsonObjectW_stringOf(jResp,L"data[i].mainDetail.ean"); mainDetailPurchasePrice = CkJsonObjectW_stringOf(jResp,L"data[i].mainDetail.purchasePrice"); mainDetailPosition = CkJsonObjectW_IntOf(jResp,L"data[i].mainDetail.position"); mainDetailMinPurchase = CkJsonObjectW_IntOf(jResp,L"data[i].mainDetail.minPurchase"); mainDetailPurchaseSteps = CkJsonObjectW_IntOf(jResp,L"data[i].mainDetail.purchaseSteps"); mainDetailMaxPurchase = CkJsonObjectW_IntOf(jResp,L"data[i].mainDetail.maxPurchase"); mainDetailPurchaseUnit = CkJsonObjectW_stringOf(jResp,L"data[i].mainDetail.purchaseUnit"); mainDetailReferenceUnit = CkJsonObjectW_stringOf(jResp,L"data[i].mainDetail.referenceUnit"); mainDetailPackUnit = CkJsonObjectW_stringOf(jResp,L"data[i].mainDetail.packUnit"); mainDetailShippingFree = CkJsonObjectW_BoolOf(jResp,L"data[i].mainDetail.shippingFree"); mainDetailReleaseDate = CkJsonObjectW_stringOf(jResp,L"data[i].mainDetail.releaseDate"); mainDetailShippingTime = CkJsonObjectW_stringOf(jResp,L"data[i].mainDetail.shippingTime"); mainDetailAttributeId = CkJsonObjectW_IntOf(jResp,L"data[i].mainDetail.attribute.id"); mainDetailAttributeArticleDetailId = CkJsonObjectW_IntOf(jResp,L"data[i].mainDetail.attribute.articleDetailId"); mainDetailAttributeAttr1 = CkJsonObjectW_stringOf(jResp,L"data[i].mainDetail.attribute.attr1"); mainDetailAttributeAttr2 = CkJsonObjectW_stringOf(jResp,L"data[i].mainDetail.attribute.attr2"); mainDetailAttributeAttr3 = CkJsonObjectW_stringOf(jResp,L"data[i].mainDetail.attribute.attr3"); mainDetailAttributeAttr4 = CkJsonObjectW_stringOf(jResp,L"data[i].mainDetail.attribute.attr4"); mainDetailAttributeAttr5 = CkJsonObjectW_stringOf(jResp,L"data[i].mainDetail.attribute.attr5"); mainDetailAttributeAttr6 = CkJsonObjectW_stringOf(jResp,L"data[i].mainDetail.attribute.attr6"); mainDetailAttributeAttr7 = CkJsonObjectW_stringOf(jResp,L"data[i].mainDetail.attribute.attr7"); mainDetailAttributeAttr8 = CkJsonObjectW_stringOf(jResp,L"data[i].mainDetail.attribute.attr8"); mainDetailAttributeAttr9 = CkJsonObjectW_stringOf(jResp,L"data[i].mainDetail.attribute.attr9"); mainDetailAttributeAttr10 = CkJsonObjectW_stringOf(jResp,L"data[i].mainDetail.attribute.attr10"); mainDetailAttributeAttr11 = CkJsonObjectW_stringOf(jResp,L"data[i].mainDetail.attribute.attr11"); mainDetailAttributeAttr12 = CkJsonObjectW_stringOf(jResp,L"data[i].mainDetail.attribute.attr12"); mainDetailAttributeAttr13 = CkJsonObjectW_stringOf(jResp,L"data[i].mainDetail.attribute.attr13"); mainDetailAttributeAttr14 = CkJsonObjectW_stringOf(jResp,L"data[i].mainDetail.attribute.attr14"); mainDetailAttributeAttr15 = CkJsonObjectW_stringOf(jResp,L"data[i].mainDetail.attribute.attr15"); mainDetailAttributeAttr16 = CkJsonObjectW_stringOf(jResp,L"data[i].mainDetail.attribute.attr16"); mainDetailAttributeAttr17 = CkJsonObjectW_stringOf(jResp,L"data[i].mainDetail.attribute.attr17"); mainDetailAttributeAttr18 = CkJsonObjectW_stringOf(jResp,L"data[i].mainDetail.attribute.attr18"); mainDetailAttributeAttr19 = CkJsonObjectW_stringOf(jResp,L"data[i].mainDetail.attribute.attr19"); mainDetailAttributeAttr20 = CkJsonObjectW_stringOf(jResp,L"data[i].mainDetail.attribute.attr20"); mainDetailAttributeApostroph = CkJsonObjectW_stringOf(jResp,L"data[i].mainDetail.attribute.apostroph"); i = i + 1; } CkHttpW_Dispose(http); CkStringBuilderW_Dispose(sbResponseBody); CkJsonObjectW_Dispose(jResp); } |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.