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
(PureBasic) 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
IncludeFile "CkJsonObject.pb" IncludeFile "CkPrivateKey.pb" IncludeFile "CkHttp.pb" IncludeFile "CkStringBuilder.pb" IncludeFile "CkHttpResponse.pb" IncludeFile "CkCert.pb" IncludeFile "CkBinData.pb" Procedure ChilkatExample() ; This example assumes the Chilkat API to have been previously unlocked. ; See Global Unlock Sample for sample code. http.i = CkHttp::ckCreate() If http.i = 0 Debug "Failed to create object." ProcedureReturn EndIf success.i ; 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.i = CkCert::ckCreate() If cert.i = 0 Debug "Failed to create object." ProcedureReturn EndIf success = CkCert::ckLoadFromFile(cert,"<nome arquivo certificado>.crt") If success = 0 Debug CkCert::ckLastErrorText(cert) CkHttp::ckDispose(http) CkCert::ckDispose(cert) ProcedureReturn EndIf bdPrivKey.i = CkBinData::ckCreate() If bdPrivKey.i = 0 Debug "Failed to create object." ProcedureReturn EndIf success = CkBinData::ckLoadFile(bdPrivKey,"<nome arquivo chave privada>.key") If success = 0 Debug "Failed to load key" CkHttp::ckDispose(http) CkCert::ckDispose(cert) CkBinData::ckDispose(bdPrivKey) ProcedureReturn EndIf ; Note: If your private key file requires a password, then set it here. ; Otherwise pass the empty string. privKeyPassword.s = "" privKey.i = CkPrivateKey::ckCreate() If privKey.i = 0 Debug "Failed to create object." ProcedureReturn EndIf success = CkPrivateKey::ckLoadAnyFormat(privKey,bdPrivKey,privKeyPassword) If success = 0 Debug CkPrivateKey::ckLastErrorText(privKey) CkHttp::ckDispose(http) CkCert::ckDispose(cert) CkBinData::ckDispose(bdPrivKey) CkPrivateKey::ckDispose(privKey) ProcedureReturn EndIf success = CkCert::ckSetPrivateKey(cert,privKey) If success = 0 Debug CkCert::ckLastErrorText(cert) CkHttp::ckDispose(http) CkCert::ckDispose(cert) CkBinData::ckDispose(bdPrivKey) CkPrivateKey::ckDispose(privKey) ProcedureReturn EndIf CkHttp::ckSetSslClientCert(http,cert) queryParams.i = CkJsonObject::ckCreate() If queryParams.i = 0 Debug "Failed to create object." ProcedureReturn EndIf CkJsonObject::ckUpdateString(queryParams,"dataInicial","2022-04-01") CkJsonObject::ckUpdateString(queryParams,"dataFinal","2022-04-03") CkJsonObject::ckUpdateString(queryParams,"situacao","VENCIDO") CkJsonObject::ckUpdateString(queryParams,"tipoOrdenacao","ASC") CkJsonObject::ckUpdateInt(queryParams,"itensPorPagina",10) CkJsonObject::ckUpdateInt(queryParams,"paginaAtual",2) ; Adds the "Authorization: Bearer $TOKEN" header. CkHttp::setCkAuthToken(http, "$TOKEN") resp.i = CkHttp::ckQuickRequestParams(http,"GET","https://cdpj.partners.bancointer.com.br/cobranca/v2/boletos",queryParams) If CkHttp::ckLastMethodSuccess(http) = 0 Debug CkHttp::ckLastErrorText(http) CkHttp::ckDispose(http) CkCert::ckDispose(cert) CkBinData::ckDispose(bdPrivKey) CkPrivateKey::ckDispose(privKey) CkJsonObject::ckDispose(queryParams) ProcedureReturn EndIf sbResponseBody.i = CkStringBuilder::ckCreate() If sbResponseBody.i = 0 Debug "Failed to create object." ProcedureReturn EndIf CkHttpResponse::ckGetBodySb(resp,sbResponseBody) jResp.i = CkJsonObject::ckCreate() If jResp.i = 0 Debug "Failed to create object." ProcedureReturn EndIf CkJsonObject::ckLoadSb(jResp,sbResponseBody) CkJsonObject::setCkEmitCompact(jResp, 0) Debug "Response Body:" Debug CkJsonObject::ckEmit(jResp) respStatusCode.i = CkHttpResponse::ckStatusCode(resp) Debug "Response Status Code = " + Str(respStatusCode) If respStatusCode >= 400 Debug "Response Header:" Debug CkHttpResponse::ckHeader(resp) Debug "Failed." CkHttpResponse::ckDispose(resp) CkHttp::ckDispose(http) CkCert::ckDispose(cert) CkBinData::ckDispose(bdPrivKey) CkPrivateKey::ckDispose(privKey) CkJsonObject::ckDispose(queryParams) CkStringBuilder::ckDispose(sbResponseBody) CkJsonObject::ckDispose(jResp) ProcedureReturn EndIf CkHttpResponse::ckDispose(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 nomeBeneficiario.s cnpjCpfBeneficiario.s totalPages.i = CkJsonObject::ckIntOf(jResp,"totalPages") totalElements.i = CkJsonObject::ckIntOf(jResp,"totalElements") last.i = CkJsonObject::ckBoolOf(jResp,"last") first.i = CkJsonObject::ckBoolOf(jResp,"first") size.i = CkJsonObject::ckIntOf(jResp,"size") numberOfElements.i = CkJsonObject::ckIntOf(jResp,"numberOfElements") i.i = 0 count_i.i = CkJsonObject::ckSizeOfArray(jResp,"content") While i < count_i CkJsonObject::setCkI(jResp, i) nomeBeneficiario = CkJsonObject::ckStringOf(jResp,"content[i].nomeBeneficiario") cnpjCpfBeneficiario = CkJsonObject::ckStringOf(jResp,"content[i].cnpjCpfBeneficiario") i = i + 1 Wend CkHttp::ckDispose(http) CkCert::ckDispose(cert) CkBinData::ckDispose(bdPrivKey) CkPrivateKey::ckDispose(privKey) CkJsonObject::ckDispose(queryParams) CkStringBuilder::ckDispose(sbResponseBody) CkJsonObject::ckDispose(jResp) ProcedureReturn EndProcedure |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.