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 CategoriesSee more Shopware ExamplesList categories in your Shopware database. For more information, see https://developers.shopware.com/developers-guide/rest-api/api-resource-categories/
#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; BOOL active; const wchar_t *name; int position; const wchar_t *parentId; const wchar_t *mediaId; const wchar_t *childrenCount; const wchar_t *articleCount; 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/categories?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": 1, // "active": true, // "name": "Root", // "position": 0, // "parentId": null, // "mediaId": null, // "childrenCount": "3", // "articleCount": "0" // }, // { // "id": 384, // "active": true, // "name": "Deutsch", // "position": 0, // "parentId": 1, // "mediaId": null, // "childrenCount": "9", // "articleCount": "32" // } // ], // "total": 118, // "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"); active = CkJsonObjectW_BoolOf(jResp,L"data[i].active"); name = CkJsonObjectW_stringOf(jResp,L"data[i].name"); position = CkJsonObjectW_IntOf(jResp,L"data[i].position"); parentId = CkJsonObjectW_stringOf(jResp,L"data[i].parentId"); mediaId = CkJsonObjectW_stringOf(jResp,L"data[i].mediaId"); childrenCount = CkJsonObjectW_stringOf(jResp,L"data[i].childrenCount"); articleCount = CkJsonObjectW_stringOf(jResp,L"data[i].articleCount"); i = i + 1; } CkHttpW_Dispose(http); CkStringBuilderW_Dispose(sbResponseBody); CkJsonObjectW_Dispose(jResp); } |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.