Sample code for 30+ languages & platforms
Xbase++

CallRail API - Retrieve a Call Recording

See more CallRail Examples

Returns a CallRail URL pointing to an MP3 recording of the specified call, and then downloads the MP3 to a local file.

Chilkat Xbase++ Downloads

Xbase++
LOCAL nSuccess
LOCAL oHttp
LOCAL oSbResponseBody
LOCAL oJResp
LOCAL nRespStatusCode
LOCAL cUrl

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 -H "Authorization: Token token=abc1234" \
//    https://api.callrail.com/v3/a/{account_id}/calls/{call_id}/recording.json

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

oHttp:SetRequestHeader("Authorization", "Token token=abc1234")

oSbResponseBody := CreateObject("Chilkat.StringBuilder")
nSuccess := oHttp:QuickGetSb("https://api.callrail.com/v3/a/{account_id}/calls/{call_id}/recording.json", 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:

//  {
//    "url": "http://app.callrail.com/calls/CAL11df32690b7d46123456789123456789/recording/redirect?access_key=241sa242sadqwerty123"
//  }

cUrl := oJResp:StringOf("url")

//  Download to a .mp3 file
nSuccess := oHttp:Download(cUrl, "call_recordings/CAL11df32690b7d46123456789123456789.mp3")
IF (nSuccess == 0)
    ? oHttp:LastErrorText
ELSE
    ? "success."
ENDIF

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