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
(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_CkHttp.h> #include <C_CkStringBuilder.h> #include <C_CkJsonObject.h> void ChilkatSample(void) { HCkHttp http; HCkStringBuilder sbResponseBody; BOOL success; HCkJsonObject jResp; int id; int mainDetailId; int supplierId; int taxId; int priceGroupId; const char *filterGroupId; const char *configuratorSetId; const char *name; const char *description; const char *descriptionLong; const char *added; BOOL active; int pseudoSales; BOOL highlight; const char *keywords; const char *metaTitle; const char *changed; BOOL priceGroupActive; BOOL lastStock; int crossBundleLook; BOOL notification; const char *template; int mode; const char *availableFrom; const char *availableTo; int mainDetailArticleId; int mainDetailUnitId; const char *mainDetailNumber; const char *mainDetailSupplierNumber; int mainDetailKind; const char *mainDetailAdditionalText; BOOL mainDetailActive; int mainDetailInStock; const char *mainDetailStockMin; BOOL mainDetailLastStock; const char *mainDetailWeight; const char *mainDetailWidth; const char *mainDetailLen; const char *mainDetailHeight; const char *mainDetailEan; const char *mainDetailPurchasePrice; int mainDetailPosition; int mainDetailMinPurchase; int mainDetailPurchaseSteps; int mainDetailMaxPurchase; const char *mainDetailPurchaseUnit; const char *mainDetailReferenceUnit; const char *mainDetailPackUnit; BOOL mainDetailShippingFree; const char *mainDetailReleaseDate; const char *mainDetailShippingTime; int mainDetailAttributeId; int mainDetailAttributeArticleDetailId; const char *mainDetailAttributeAttr1; const char *mainDetailAttributeAttr2; const char *mainDetailAttributeAttr3; const char *mainDetailAttributeAttr4; const char *mainDetailAttributeAttr5; const char *mainDetailAttributeAttr6; const char *mainDetailAttributeAttr7; const char *mainDetailAttributeAttr8; const char *mainDetailAttributeAttr9; const char *mainDetailAttributeAttr10; const char *mainDetailAttributeAttr11; const char *mainDetailAttributeAttr12; const char *mainDetailAttributeAttr13; const char *mainDetailAttributeAttr14; const char *mainDetailAttributeAttr15; const char *mainDetailAttributeAttr16; const char *mainDetailAttributeAttr17; const char *mainDetailAttributeAttr18; const char *mainDetailAttributeAttr19; const char *mainDetailAttributeAttr20; const char *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 = CkHttp_Create(); CkHttp_putLogin(http,"api_username"); CkHttp_putPassword(http,"api_key"); CkHttp_putBasicAuth(http,TRUE); sbResponseBody = CkStringBuilder_Create(); success = CkHttp_QuickGetSb(http,"https://my-shopware-shop.com/api/articles?limit=2",sbResponseBody); if (success == FALSE) { printf("%s\n",CkHttp_lastErrorText(http)); CkHttp_Dispose(http); CkStringBuilder_Dispose(sbResponseBody); return; } jResp = CkJsonObject_Create(); CkJsonObject_LoadSb(jResp,sbResponseBody); CkJsonObject_putEmitCompact(jResp,FALSE); printf("Response Body:\n"); printf("%s\n",CkJsonObject_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 = CkJsonObject_IntOf(jResp,"total"); success = CkJsonObject_BoolOf(jResp,"success"); i = 0; count_i = CkJsonObject_SizeOfArray(jResp,"data"); while (i < count_i) { CkJsonObject_putI(jResp,i); id = CkJsonObject_IntOf(jResp,"data[i].id"); mainDetailId = CkJsonObject_IntOf(jResp,"data[i].mainDetailId"); supplierId = CkJsonObject_IntOf(jResp,"data[i].supplierId"); taxId = CkJsonObject_IntOf(jResp,"data[i].taxId"); priceGroupId = CkJsonObject_IntOf(jResp,"data[i].priceGroupId"); filterGroupId = CkJsonObject_stringOf(jResp,"data[i].filterGroupId"); configuratorSetId = CkJsonObject_stringOf(jResp,"data[i].configuratorSetId"); name = CkJsonObject_stringOf(jResp,"data[i].name"); description = CkJsonObject_stringOf(jResp,"data[i].description"); descriptionLong = CkJsonObject_stringOf(jResp,"data[i].descriptionLong"); added = CkJsonObject_stringOf(jResp,"data[i].added"); active = CkJsonObject_BoolOf(jResp,"data[i].active"); pseudoSales = CkJsonObject_IntOf(jResp,"data[i].pseudoSales"); highlight = CkJsonObject_BoolOf(jResp,"data[i].highlight"); keywords = CkJsonObject_stringOf(jResp,"data[i].keywords"); metaTitle = CkJsonObject_stringOf(jResp,"data[i].metaTitle"); changed = CkJsonObject_stringOf(jResp,"data[i].changed"); priceGroupActive = CkJsonObject_BoolOf(jResp,"data[i].priceGroupActive"); lastStock = CkJsonObject_BoolOf(jResp,"data[i].lastStock"); crossBundleLook = CkJsonObject_IntOf(jResp,"data[i].crossBundleLook"); notification = CkJsonObject_BoolOf(jResp,"data[i].notification"); template = CkJsonObject_stringOf(jResp,"data[i].template"); mode = CkJsonObject_IntOf(jResp,"data[i].mode"); availableFrom = CkJsonObject_stringOf(jResp,"data[i].availableFrom"); availableTo = CkJsonObject_stringOf(jResp,"data[i].availableTo"); mainDetailId = CkJsonObject_IntOf(jResp,"data[i].mainDetail.id"); mainDetailArticleId = CkJsonObject_IntOf(jResp,"data[i].mainDetail.articleId"); mainDetailUnitId = CkJsonObject_IntOf(jResp,"data[i].mainDetail.unitId"); mainDetailNumber = CkJsonObject_stringOf(jResp,"data[i].mainDetail.number"); mainDetailSupplierNumber = CkJsonObject_stringOf(jResp,"data[i].mainDetail.supplierNumber"); mainDetailKind = CkJsonObject_IntOf(jResp,"data[i].mainDetail.kind"); mainDetailAdditionalText = CkJsonObject_stringOf(jResp,"data[i].mainDetail.additionalText"); mainDetailActive = CkJsonObject_BoolOf(jResp,"data[i].mainDetail.active"); mainDetailInStock = CkJsonObject_IntOf(jResp,"data[i].mainDetail.inStock"); mainDetailStockMin = CkJsonObject_stringOf(jResp,"data[i].mainDetail.stockMin"); mainDetailLastStock = CkJsonObject_BoolOf(jResp,"data[i].mainDetail.lastStock"); mainDetailWeight = CkJsonObject_stringOf(jResp,"data[i].mainDetail.weight"); mainDetailWidth = CkJsonObject_stringOf(jResp,"data[i].mainDetail.width"); mainDetailLen = CkJsonObject_stringOf(jResp,"data[i].mainDetail.len"); mainDetailHeight = CkJsonObject_stringOf(jResp,"data[i].mainDetail.height"); mainDetailEan = CkJsonObject_stringOf(jResp,"data[i].mainDetail.ean"); mainDetailPurchasePrice = CkJsonObject_stringOf(jResp,"data[i].mainDetail.purchasePrice"); mainDetailPosition = CkJsonObject_IntOf(jResp,"data[i].mainDetail.position"); mainDetailMinPurchase = CkJsonObject_IntOf(jResp,"data[i].mainDetail.minPurchase"); mainDetailPurchaseSteps = CkJsonObject_IntOf(jResp,"data[i].mainDetail.purchaseSteps"); mainDetailMaxPurchase = CkJsonObject_IntOf(jResp,"data[i].mainDetail.maxPurchase"); mainDetailPurchaseUnit = CkJsonObject_stringOf(jResp,"data[i].mainDetail.purchaseUnit"); mainDetailReferenceUnit = CkJsonObject_stringOf(jResp,"data[i].mainDetail.referenceUnit"); mainDetailPackUnit = CkJsonObject_stringOf(jResp,"data[i].mainDetail.packUnit"); mainDetailShippingFree = CkJsonObject_BoolOf(jResp,"data[i].mainDetail.shippingFree"); mainDetailReleaseDate = CkJsonObject_stringOf(jResp,"data[i].mainDetail.releaseDate"); mainDetailShippingTime = CkJsonObject_stringOf(jResp,"data[i].mainDetail.shippingTime"); mainDetailAttributeId = CkJsonObject_IntOf(jResp,"data[i].mainDetail.attribute.id"); mainDetailAttributeArticleDetailId = CkJsonObject_IntOf(jResp,"data[i].mainDetail.attribute.articleDetailId"); mainDetailAttributeAttr1 = CkJsonObject_stringOf(jResp,"data[i].mainDetail.attribute.attr1"); mainDetailAttributeAttr2 = CkJsonObject_stringOf(jResp,"data[i].mainDetail.attribute.attr2"); mainDetailAttributeAttr3 = CkJsonObject_stringOf(jResp,"data[i].mainDetail.attribute.attr3"); mainDetailAttributeAttr4 = CkJsonObject_stringOf(jResp,"data[i].mainDetail.attribute.attr4"); mainDetailAttributeAttr5 = CkJsonObject_stringOf(jResp,"data[i].mainDetail.attribute.attr5"); mainDetailAttributeAttr6 = CkJsonObject_stringOf(jResp,"data[i].mainDetail.attribute.attr6"); mainDetailAttributeAttr7 = CkJsonObject_stringOf(jResp,"data[i].mainDetail.attribute.attr7"); mainDetailAttributeAttr8 = CkJsonObject_stringOf(jResp,"data[i].mainDetail.attribute.attr8"); mainDetailAttributeAttr9 = CkJsonObject_stringOf(jResp,"data[i].mainDetail.attribute.attr9"); mainDetailAttributeAttr10 = CkJsonObject_stringOf(jResp,"data[i].mainDetail.attribute.attr10"); mainDetailAttributeAttr11 = CkJsonObject_stringOf(jResp,"data[i].mainDetail.attribute.attr11"); mainDetailAttributeAttr12 = CkJsonObject_stringOf(jResp,"data[i].mainDetail.attribute.attr12"); mainDetailAttributeAttr13 = CkJsonObject_stringOf(jResp,"data[i].mainDetail.attribute.attr13"); mainDetailAttributeAttr14 = CkJsonObject_stringOf(jResp,"data[i].mainDetail.attribute.attr14"); mainDetailAttributeAttr15 = CkJsonObject_stringOf(jResp,"data[i].mainDetail.attribute.attr15"); mainDetailAttributeAttr16 = CkJsonObject_stringOf(jResp,"data[i].mainDetail.attribute.attr16"); mainDetailAttributeAttr17 = CkJsonObject_stringOf(jResp,"data[i].mainDetail.attribute.attr17"); mainDetailAttributeAttr18 = CkJsonObject_stringOf(jResp,"data[i].mainDetail.attribute.attr18"); mainDetailAttributeAttr19 = CkJsonObject_stringOf(jResp,"data[i].mainDetail.attribute.attr19"); mainDetailAttributeAttr20 = CkJsonObject_stringOf(jResp,"data[i].mainDetail.attribute.attr20"); mainDetailAttributeApostroph = CkJsonObject_stringOf(jResp,"data[i].mainDetail.attribute.apostroph"); i = i + 1; } CkHttp_Dispose(http); CkStringBuilder_Dispose(sbResponseBody); CkJsonObject_Dispose(jResp); } |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.