Sample code for 30+ languages & platforms
Xbase++

Cerved API Entity Contacts

See more Cerved Examples

The service returns the list of contacts of a Subject (legal entities) identified by "id_soggetto"

Chilkat Xbase++ Downloads

Xbase++
LOCAL nSuccess
LOCAL oHttp
LOCAL oSbResponseBody
LOCAL oJResp
LOCAL nRespStatusCode
LOCAL cEmail
LOCAL cCategoria
LOCAL cFonte
LOCAL cSede
LOCAL cNumero
LOCAL cUso
LOCAL cUrl
LOCAL cTipo
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 \
//    https://api.cerved.com/cervedApi/v1/entityProfile/contacts?id_soggetto=12345678 \
//    -H 'accept: application/json' \
//    -H 'apikey: ********************************'

//  Use the following online tool to generate HTTP code from a CURL command
//  Convert a cURL Command to HTTP Source Code

oHttp:SetRequestHeader("accept", "application/json")
oHttp:SetRequestHeader("apikey", "********************************")

oSbResponseBody := CreateObject("Chilkat.StringBuilder")
nSuccess := oHttp:QuickGetSb("https://api.cerved.com/cervedApi/v1/entityProfile/contacts?id_soggetto=12345678", oSbResponseBody)
IF (nSuccess == 0)
    ? oHttp:LastErrorText
    oHttp:destroy()
    oSbResponseBody:destroy()
    RETURN
ENDIF

oJResp := CreateObject("Chilkat.JsonObject")
oJResp:LoadSb(oSbResponseBody)
oJResp:EmitCompact := 0

? "Response Body:"
? oJResp:Emit()

nRespStatusCode := oHttp:LastStatus
? "Response Status Code = " + Str(nRespStatusCode)
IF (nRespStatusCode >= 400)
    ? "Response Header:"
    ? oHttp:LastHeader
    ? "Failed."
    oHttp:destroy()
    oSbResponseBody:destroy()
    oJResp:destroy()
    RETURN
ENDIF

//  Sample JSON response:
//  (Sample code for parsing the JSON response is shown below)

//  {
//    "indirizzi_email": [
//      {
//        "email": "string",
//        "categoria": "string"
//      }
//    ],
//    "indirizzi_email_certificate": [
//      {
//        "email": "string",
//        "categoria": "string"
//      }
//    ],
//    "telefoni": [
//      {
//        "fonte": "string",
//        "sede": "string",
//        "numero": "string",
//        "uso": "string"
//      }
//    ],
//    "siti_web": [
//      {
//        "url": "string",
//        "tipo": "string"
//      }
//    ]
//  }

//  Sample code for parsing the JSON response...
//  Use the following online tool to generate parsing code from sample JSON:
//  Generate Parsing Code from JSON

i := 0
nCount_i := oJResp:SizeOfArray("indirizzi_email")
DO WHILE i < nCount_i
    oJResp:I := i
    cEmail := oJResp:StringOf("indirizzi_email[i].email")
    cCategoria := oJResp:StringOf("indirizzi_email[i].categoria")
    i := i + 1
ENDDO
i := 0
nCount_i := oJResp:SizeOfArray("indirizzi_email_certificate")
DO WHILE i < nCount_i
    oJResp:I := i
    cEmail := oJResp:StringOf("indirizzi_email_certificate[i].email")
    cCategoria := oJResp:StringOf("indirizzi_email_certificate[i].categoria")
    i := i + 1
ENDDO
i := 0
nCount_i := oJResp:SizeOfArray("telefoni")
DO WHILE i < nCount_i
    oJResp:I := i
    cFonte := oJResp:StringOf("telefoni[i].fonte")
    cSede := oJResp:StringOf("telefoni[i].sede")
    cNumero := oJResp:StringOf("telefoni[i].numero")
    cUso := oJResp:StringOf("telefoni[i].uso")
    i := i + 1
ENDDO
i := 0
nCount_i := oJResp:SizeOfArray("siti_web")
DO WHILE i < nCount_i
    oJResp:I := i
    cUrl := oJResp:StringOf("siti_web[i].url")
    cTipo := oJResp:StringOf("siti_web[i].tipo")
    i := i + 1
ENDDO

oHttp:destroy()
oSbResponseBody:destroy()
oJResp:destroy()