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) Isabel Connect List AccountsSee more Ibanity ExamplesGet a list of accounts. For more information, see https://documentation.ibanity.com/isabel-connect/api#list-accounts
#include <C_CkHttpW.h> #include <C_CkJsonObjectW.h> void ChilkatSample(void) { HCkHttpW http; BOOL success; HCkJsonObjectW jsonToken; const wchar_t *jsonStr; HCkJsonObjectW jResp; int respStatusCode; const wchar_t *id; const wchar_t *v_type; int metaPagingOffset; int metaPagingTotal; 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(); // Implements the following CURL command: // curl -X GET https://api.ibanity.com/isabel-connect/accounts \ // --cert certificate.pem:qwertyuiop1 \ // --key private_key.pem \ // -H "Authorization: Bearer access_token_1603365407" \ // -H "Accept: application/vnd.api+json" // Ibanity provides the certificate + private key in PFX format. This example will use the .pfx instead of the pair of PEM files. // (It is also possible to implement using Chilkat with the PEM files, but PFX is easier.) success = CkHttpW_SetSslClientCertPfx(http,L"qa_data/pfx/my_ibanity_certificate.pfx",L"my_pfx_password"); if (success == FALSE) { wprintf(L"%s\n",CkHttpW_lastErrorText(http)); CkHttpW_Dispose(http); return; } // Load the previously obtained access token. jsonToken = CkJsonObjectW_Create(); success = CkJsonObjectW_LoadFile(jsonToken,L"qa_data/tokens/isabel_access_token.json"); if (success == FALSE) { wprintf(L"No existing access token.\n"); CkHttpW_Dispose(http); CkJsonObjectW_Dispose(jsonToken); return; } // This causes the "Authorization: Bearer ***" header to be added to the HTTP request. CkHttpW_putAuthToken(http,CkJsonObjectW_stringOf(jsonToken,L"access_token")); CkHttpW_putAccept(http,L"application/vnd.api+json"); jsonStr = CkHttpW_quickGetStr(http,L"https://api.ibanity.com/isabel-connect/accounts"); if (CkHttpW_getLastMethodSuccess(http) == FALSE) { wprintf(L"%s\n",CkHttpW_lastErrorText(http)); CkHttpW_Dispose(http); CkJsonObjectW_Dispose(jsonToken); return; } jResp = CkJsonObjectW_Create(); CkJsonObjectW_Load(jResp,jsonStr); CkJsonObjectW_putEmitCompact(jResp,FALSE); wprintf(L"Response Body:\n"); wprintf(L"%s\n",CkJsonObjectW_emit(jResp)); respStatusCode = CkHttpW_getLastStatus(http); wprintf(L"Response Status Code = %d\n",respStatusCode); if (respStatusCode >= 400) { wprintf(L"Response Header:\n"); wprintf(L"%s\n",CkHttpW_lastResponseHeader(http)); wprintf(L"Failed.\n"); CkHttpW_Dispose(http); CkJsonObjectW_Dispose(jsonToken); CkJsonObjectW_Dispose(jResp); return; } // Sample JSON response: // (Sample code for parsing the JSON response is shown below) // { // "data": [ // { // "id": "93ecb1fdbfb7848e7b7896c0f2d207aed3d8b4c1", // "type": "account" // } // ], // "meta": { // "paging": { // "offset": 0, // "total": 1 // } // } // } // Sample code for parsing the JSON response... // Use the following online tool to generate parsing code from sample JSON: // Generate Parsing Code from JSON metaPagingOffset = CkJsonObjectW_IntOf(jResp,L"meta.paging.offset"); metaPagingTotal = CkJsonObjectW_IntOf(jResp,L"meta.paging.total"); i = 0; count_i = CkJsonObjectW_SizeOfArray(jResp,L"data"); while (i < count_i) { CkJsonObjectW_putI(jResp,i); id = CkJsonObjectW_stringOf(jResp,L"data[i].id"); v_type = CkJsonObjectW_stringOf(jResp,L"data[i].type"); i = i + 1; } CkHttpW_Dispose(http); CkJsonObjectW_Dispose(jsonToken); CkJsonObjectW_Dispose(jResp); } |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.