Visual FoxPro
Visual FoxPro
Clickatell Get Account Balance
See more Clickatell Examples
This will return the balance for the account associated with the given API-key.Chilkat Visual FoxPro Downloads
LOCAL lnSuccess
LOCAL loHttp
LOCAL loSbResponseBody
LOCAL loJResp
LOCAL lnRespStatusCode
LOCAL lcBalance
LOCAL lcCurrency
lnSuccess = 0
* This example assumes the Chilkat API to have been previously unlocked.
* See Global Unlock Sample for sample code.
loHttp = CreateObject('Chilkat.Http')
* Implements the following CURL command:
* curl -X GET --header 'Accept: application/json' \
* --header 'Authorization: API_KEY'
* https://platform.clickatell.com/public-client/balance
loHttp.SetRequestHeader("Authorization","API_KEY")
loHttp.SetRequestHeader("Accept","application/json")
loSbResponseBody = CreateObject('Chilkat.StringBuilder')
lnSuccess = loHttp.QuickGetSb("https://platform.clickatell.com/public-client/balance",loSbResponseBody)
IF (lnSuccess = 0) THEN
? loHttp.LastErrorText
RELEASE loHttp
RELEASE loSbResponseBody
CANCEL
ENDIF
loJResp = CreateObject('Chilkat.JsonObject')
loJResp.LoadSb(loSbResponseBody)
loJResp.EmitCompact = 0
? "Response Body:"
? loJResp.Emit()
lnRespStatusCode = loHttp.LastStatus
? "Response Status Code = " + STR(lnRespStatusCode)
IF (lnRespStatusCode >= 400) THEN
? "Response Header:"
? loHttp.LastHeader
? "Failed."
RELEASE loHttp
RELEASE loSbResponseBody
RELEASE loJResp
CANCEL
ENDIF
* Sample JSON response:
* (Sample code for parsing the JSON response is shown below)
* {
* "balance": 1267.92865,
* "currency": "ZAR"
* }
* Sample code for parsing the JSON response...
* Use the following online tool to generate parsing code from sample JSON:
* Generate Parsing Code from JSON
lcBalance = loJResp.StringOf("balance")
lcCurrency = loJResp.StringOf("currency")
RELEASE loHttp
RELEASE loSbResponseBody
RELEASE loJResp