Xbase++ Requires Chilkat v11.0.0+
Xbase++
Banco Inter Obtendo uma lista de boletos
See more Banco Inter Examples
Get a list of tickets that match the search criteria.Chilkat Xbase++ Downloads
LOCAL nSuccess
LOCAL oHttp
LOCAL oCert
LOCAL oBdPrivKey
LOCAL cPrivKeyPassword
LOCAL oPrivKey
LOCAL oQueryParams
LOCAL oResp
LOCAL oSbResponseBody
LOCAL oJResp
LOCAL nRespStatusCode
LOCAL cNomeBeneficiario
LOCAL cCnpjCpfBeneficiario
LOCAL nTotalPages
LOCAL nTotalElements
LOCAL nLast
LOCAL nFirst
LOCAL nSize
LOCAL nNumberOfElements
LOCAL i
LOCAL nCount_i
nSuccess := 0
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
oHttp := CreateObject("Chilkat.Http")
// 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
oCert := CreateObject("Chilkat.Cert")
nSuccess := oCert:LoadFromFile("<nome arquivo certificado>.crt")
IF (nSuccess == 0)
? oCert:LastErrorText
oHttp:destroy()
oCert:destroy()
RETURN
ENDIF
oBdPrivKey := CreateObject("Chilkat.BinData")
nSuccess := oBdPrivKey:LoadFile("<nome arquivo chave privada>.key")
IF (nSuccess == 0)
? "Failed to load key"
oHttp:destroy()
oCert:destroy()
oBdPrivKey:destroy()
RETURN
ENDIF
// Note: If your private key file requires a password, then set it here.
// Otherwise pass the empty string.
cPrivKeyPassword := ""
oPrivKey := CreateObject("Chilkat.PrivateKey")
nSuccess := oPrivKey:LoadAnyFormat(oBdPrivKey, cPrivKeyPassword)
IF (nSuccess == 0)
? oPrivKey:LastErrorText
oHttp:destroy()
oCert:destroy()
oBdPrivKey:destroy()
oPrivKey:destroy()
RETURN
ENDIF
nSuccess := oCert:SetPrivateKey(oPrivKey)
IF (nSuccess == 0)
? oCert:LastErrorText
oHttp:destroy()
oCert:destroy()
oBdPrivKey:destroy()
oPrivKey:destroy()
RETURN
ENDIF
oHttp:SetSslClientCert(oCert)
oQueryParams := CreateObject("Chilkat.JsonObject")
oQueryParams:UpdateString("dataInicial", "2022-04-01")
oQueryParams:UpdateString("dataFinal", "2022-04-03")
oQueryParams:UpdateString("situacao", "VENCIDO")
oQueryParams:UpdateString("tipoOrdenacao", "ASC")
oQueryParams:UpdateInt("itensPorPagina", 10)
oQueryParams:UpdateInt("paginaAtual", 2)
// Adds the "Authorization: Bearer $TOKEN" header.
oHttp:AuthToken := "$TOKEN"
oResp := CreateObject("Chilkat.HttpResponse")
nSuccess := oHttp:HttpParams("GET", "https://cdpj.partners.bancointer.com.br/cobranca/v2/boletos", oQueryParams, oResp)
IF (nSuccess == 0)
? oHttp:LastErrorText
oHttp:destroy()
oCert:destroy()
oBdPrivKey:destroy()
oPrivKey:destroy()
oQueryParams:destroy()
oResp:destroy()
RETURN
ENDIF
oSbResponseBody := CreateObject("Chilkat.StringBuilder")
oResp:GetBodySb(oSbResponseBody)
oJResp := CreateObject("Chilkat.JsonObject")
oJResp:LoadSb(oSbResponseBody)
oJResp:EmitCompact := 0
? "Response Body:"
? oJResp:Emit()
nRespStatusCode := oResp:StatusCode
? "Response Status Code = " + Str(nRespStatusCode)
IF (nRespStatusCode >= 400)
? "Response Header:"
? oResp:Header
? "Failed."
oHttp:destroy()
oCert:destroy()
oBdPrivKey:destroy()
oPrivKey:destroy()
oQueryParams:destroy()
oResp:destroy()
oSbResponseBody:destroy()
oJResp:destroy()
RETURN
ENDIF
// 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
nTotalPages := oJResp:IntOf("totalPages")
nTotalElements := oJResp:IntOf("totalElements")
nLast := oJResp:BoolOf("last")
nFirst := oJResp:BoolOf("first")
nSize := oJResp:IntOf("size")
nNumberOfElements := oJResp:IntOf("numberOfElements")
i := 0
nCount_i := oJResp:SizeOfArray("content")
DO WHILE i < nCount_i
oJResp:I := i
cNomeBeneficiario := oJResp:StringOf("content[i].nomeBeneficiario")
cCnpjCpfBeneficiario := oJResp:StringOf("content[i].cnpjCpfBeneficiario")
i := i + 1
ENDDO
oHttp:destroy()
oCert:destroy()
oBdPrivKey:destroy()
oPrivKey:destroy()
oQueryParams:destroy()
oResp:destroy()
oSbResponseBody:destroy()
oJResp:destroy()