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) 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_CkHttp.h> #include <C_CkCert.h> #include <C_CkBinData.h> #include <C_CkPrivateKey.h> #include <C_CkJsonObject.h> #include <C_CkHttpResponse.h> #include <C_CkStringBuilder.h> void ChilkatSample(void) { HCkHttp http; BOOL success; HCkCert cert; HCkBinData bdPrivKey; const char *privKeyPassword; HCkPrivateKey privKey; HCkJsonObject queryParams; HCkHttpResponse resp; HCkStringBuilder sbResponseBody; HCkJsonObject jResp; int respStatusCode; const char *nomeBeneficiario; const char *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 = CkHttp_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 = CkCert_Create(); success = CkCert_LoadFromFile(cert,"<nome arquivo certificado>.crt"); if (success == FALSE) { printf("%s\n",CkCert_lastErrorText(cert)); CkHttp_Dispose(http); CkCert_Dispose(cert); return; } bdPrivKey = CkBinData_Create(); success = CkBinData_LoadFile(bdPrivKey,"<nome arquivo chave privada>.key"); if (success == FALSE) { printf("Failed to load key\n"); CkHttp_Dispose(http); CkCert_Dispose(cert); CkBinData_Dispose(bdPrivKey); return; } // Note: If your private key file requires a password, then set it here. // Otherwise pass the empty string. privKeyPassword = ""; privKey = CkPrivateKey_Create(); success = CkPrivateKey_LoadAnyFormat(privKey,bdPrivKey,privKeyPassword); if (success == FALSE) { printf("%s\n",CkPrivateKey_lastErrorText(privKey)); CkHttp_Dispose(http); CkCert_Dispose(cert); CkBinData_Dispose(bdPrivKey); CkPrivateKey_Dispose(privKey); return; } success = CkCert_SetPrivateKey(cert,privKey); if (success == FALSE) { printf("%s\n",CkCert_lastErrorText(cert)); CkHttp_Dispose(http); CkCert_Dispose(cert); CkBinData_Dispose(bdPrivKey); CkPrivateKey_Dispose(privKey); return; } CkHttp_SetSslClientCert(http,cert); queryParams = CkJsonObject_Create(); CkJsonObject_UpdateString(queryParams,"dataInicial","2022-04-01"); CkJsonObject_UpdateString(queryParams,"dataFinal","2022-04-03"); CkJsonObject_UpdateString(queryParams,"situacao","VENCIDO"); CkJsonObject_UpdateString(queryParams,"tipoOrdenacao","ASC"); CkJsonObject_UpdateInt(queryParams,"itensPorPagina",10); CkJsonObject_UpdateInt(queryParams,"paginaAtual",2); // Adds the "Authorization: Bearer $TOKEN" header. CkHttp_putAuthToken(http,"$TOKEN"); resp = CkHttp_QuickRequestParams(http,"GET","https://cdpj.partners.bancointer.com.br/cobranca/v2/boletos",queryParams); if (CkHttp_getLastMethodSuccess(http) == FALSE) { printf("%s\n",CkHttp_lastErrorText(http)); CkHttp_Dispose(http); CkCert_Dispose(cert); CkBinData_Dispose(bdPrivKey); CkPrivateKey_Dispose(privKey); CkJsonObject_Dispose(queryParams); return; } sbResponseBody = CkStringBuilder_Create(); CkHttpResponse_GetBodySb(resp,sbResponseBody); jResp = CkJsonObject_Create(); CkJsonObject_LoadSb(jResp,sbResponseBody); CkJsonObject_putEmitCompact(jResp,FALSE); printf("Response Body:\n"); printf("%s\n",CkJsonObject_emit(jResp)); respStatusCode = CkHttpResponse_getStatusCode(resp); printf("Response Status Code = %d\n",respStatusCode); if (respStatusCode >= 400) { printf("Response Header:\n"); printf("%s\n",CkHttpResponse_header(resp)); printf("Failed.\n"); CkHttpResponse_Dispose(resp); CkHttp_Dispose(http); CkCert_Dispose(cert); CkBinData_Dispose(bdPrivKey); CkPrivateKey_Dispose(privKey); CkJsonObject_Dispose(queryParams); CkStringBuilder_Dispose(sbResponseBody); CkJsonObject_Dispose(jResp); return; } CkHttpResponse_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 = CkJsonObject_IntOf(jResp,"totalPages"); totalElements = CkJsonObject_IntOf(jResp,"totalElements"); last = CkJsonObject_BoolOf(jResp,"last"); first = CkJsonObject_BoolOf(jResp,"first"); size = CkJsonObject_IntOf(jResp,"size"); numberOfElements = CkJsonObject_IntOf(jResp,"numberOfElements"); i = 0; count_i = CkJsonObject_SizeOfArray(jResp,"content"); while (i < count_i) { CkJsonObject_putI(jResp,i); nomeBeneficiario = CkJsonObject_stringOf(jResp,"content[i].nomeBeneficiario"); cnpjCpfBeneficiario = CkJsonObject_stringOf(jResp,"content[i].cnpjCpfBeneficiario"); i = i + 1; } CkHttp_Dispose(http); CkCert_Dispose(cert); CkBinData_Dispose(bdPrivKey); CkPrivateKey_Dispose(privKey); CkJsonObject_Dispose(queryParams); CkStringBuilder_Dispose(sbResponseBody); CkJsonObject_Dispose(jResp); } |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.