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) Banco Inter Obtendo uma lista de boletosSee more Banco Inter ExamplesGet a list of tickets that match the search criteria. For more information, see https://developers.bancointer.com.br/reference/pesquisarboletos
#include <C_CkHttpW.h> #include <C_CkCertW.h> #include <C_CkBinDataW.h> #include <C_CkPrivateKeyW.h> #include <C_CkJsonObjectW.h> #include <C_CkHttpResponseW.h> #include <C_CkStringBuilderW.h> void ChilkatSample(void) { HCkHttpW http; BOOL success; HCkCertW cert; HCkBinDataW bdPrivKey; const wchar_t *privKeyPassword; HCkPrivateKeyW privKey; HCkJsonObjectW queryParams; HCkHttpResponseW resp; HCkStringBuilderW sbResponseBody; HCkJsonObjectW jResp; int respStatusCode; const wchar_t *nomeBeneficiario; const wchar_t *cnpjCpfBeneficiario; int totalPages; int totalElements; BOOL last; BOOL first; int size; int numberOfElements; 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 \ // -H "Authorization: Bearer $TOKEN" \ // --cert <nome arquivo certificado>.crt \ // --key <nome arquivo chave privada>.key \ // --get \ // --data-urlencode "dataInicial=2022-04-01" \ // --data-urlencode "dataFinal=2022-04-03" \ // --data-urlencode "situacao=VENCIDO" \ // --data-urlencode "tipoOrdenacao=ASC" \ // --data-urlencode "itensPorPagina=10" \ // --data-urlencode "paginaAtual=2" \ // https://cdpj.partners.bancointer.com.br/cobranca/v2/boletos // Use the following online tool to generate HTTP code from a CURL command // Convert a cURL Command to HTTP Source Code cert = CkCertW_Create(); success = CkCertW_LoadFromFile(cert,L"<nome arquivo certificado>.crt"); if (success == FALSE) { wprintf(L"%s\n",CkCertW_lastErrorText(cert)); CkHttpW_Dispose(http); CkCertW_Dispose(cert); return; } bdPrivKey = CkBinDataW_Create(); success = CkBinDataW_LoadFile(bdPrivKey,L"<nome arquivo chave privada>.key"); if (success == FALSE) { wprintf(L"Failed to load key\n"); CkHttpW_Dispose(http); CkCertW_Dispose(cert); CkBinDataW_Dispose(bdPrivKey); return; } // Note: If your private key file requires a password, then set it here. // Otherwise pass the empty string. privKeyPassword = L""; privKey = CkPrivateKeyW_Create(); success = CkPrivateKeyW_LoadAnyFormat(privKey,bdPrivKey,privKeyPassword); if (success == FALSE) { wprintf(L"%s\n",CkPrivateKeyW_lastErrorText(privKey)); CkHttpW_Dispose(http); CkCertW_Dispose(cert); CkBinDataW_Dispose(bdPrivKey); CkPrivateKeyW_Dispose(privKey); return; } success = CkCertW_SetPrivateKey(cert,privKey); if (success == FALSE) { wprintf(L"%s\n",CkCertW_lastErrorText(cert)); CkHttpW_Dispose(http); CkCertW_Dispose(cert); CkBinDataW_Dispose(bdPrivKey); CkPrivateKeyW_Dispose(privKey); return; } CkHttpW_SetSslClientCert(http,cert); queryParams = CkJsonObjectW_Create(); CkJsonObjectW_UpdateString(queryParams,L"dataInicial",L"2022-04-01"); CkJsonObjectW_UpdateString(queryParams,L"dataFinal",L"2022-04-03"); CkJsonObjectW_UpdateString(queryParams,L"situacao",L"VENCIDO"); CkJsonObjectW_UpdateString(queryParams,L"tipoOrdenacao",L"ASC"); CkJsonObjectW_UpdateInt(queryParams,L"itensPorPagina",10); CkJsonObjectW_UpdateInt(queryParams,L"paginaAtual",2); // Adds the "Authorization: Bearer $TOKEN" header. CkHttpW_putAuthToken(http,L"$TOKEN"); resp = CkHttpW_QuickRequestParams(http,L"GET",L"https://cdpj.partners.bancointer.com.br/cobranca/v2/boletos",queryParams); if (CkHttpW_getLastMethodSuccess(http) == FALSE) { wprintf(L"%s\n",CkHttpW_lastErrorText(http)); CkHttpW_Dispose(http); CkCertW_Dispose(cert); CkBinDataW_Dispose(bdPrivKey); CkPrivateKeyW_Dispose(privKey); CkJsonObjectW_Dispose(queryParams); return; } sbResponseBody = CkStringBuilderW_Create(); CkHttpResponseW_GetBodySb(resp,sbResponseBody); jResp = CkJsonObjectW_Create(); CkJsonObjectW_LoadSb(jResp,sbResponseBody); CkJsonObjectW_putEmitCompact(jResp,FALSE); wprintf(L"Response Body:\n"); wprintf(L"%s\n",CkJsonObjectW_emit(jResp)); respStatusCode = CkHttpResponseW_getStatusCode(resp); wprintf(L"Response Status Code = %d\n",respStatusCode); if (respStatusCode >= 400) { wprintf(L"Response Header:\n"); wprintf(L"%s\n",CkHttpResponseW_header(resp)); wprintf(L"Failed.\n"); CkHttpResponseW_Dispose(resp); CkHttpW_Dispose(http); CkCertW_Dispose(cert); CkBinDataW_Dispose(bdPrivKey); CkPrivateKeyW_Dispose(privKey); CkJsonObjectW_Dispose(queryParams); CkStringBuilderW_Dispose(sbResponseBody); CkJsonObjectW_Dispose(jResp); return; } CkHttpResponseW_Dispose(resp); // Sample JSON response: // (Sample code for parsing the JSON response is shown below) // { // "totalPages": 1, // "totalElements": 58, // "last": true, // "first": true, // "size": 100, // "numberOfElements": 58, // "content": [ // { // "nomeBeneficiario": "nome do beneficiario 1", // "cnpjCpfBeneficiario": "CNPJ/CPF beneficiario 1" // }, // { // "nomeBeneficiario": "nome do beneficiario 2", // "cnpjCpfBeneficiario": "CNPJ/CPF beneficiario 2" // }, // { // "nomeBeneficiario": "nome do beneficiario N", // "cnpjCpfBeneficiario": "CNPJ/CPF beneficiario N" // } // ] // } // 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. totalPages = CkJsonObjectW_IntOf(jResp,L"totalPages"); totalElements = CkJsonObjectW_IntOf(jResp,L"totalElements"); last = CkJsonObjectW_BoolOf(jResp,L"last"); first = CkJsonObjectW_BoolOf(jResp,L"first"); size = CkJsonObjectW_IntOf(jResp,L"size"); numberOfElements = CkJsonObjectW_IntOf(jResp,L"numberOfElements"); i = 0; count_i = CkJsonObjectW_SizeOfArray(jResp,L"content"); while (i < count_i) { CkJsonObjectW_putI(jResp,i); nomeBeneficiario = CkJsonObjectW_stringOf(jResp,L"content[i].nomeBeneficiario"); cnpjCpfBeneficiario = CkJsonObjectW_stringOf(jResp,L"content[i].cnpjCpfBeneficiario"); i = i + 1; } CkHttpW_Dispose(http); CkCertW_Dispose(cert); CkBinDataW_Dispose(bdPrivKey); CkPrivateKeyW_Dispose(privKey); CkJsonObjectW_Dispose(queryParams); CkStringBuilderW_Dispose(sbResponseBody); CkJsonObjectW_Dispose(jResp); } |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.