Sample code for 30+ languages & platforms
Lianja

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 Lianja Downloads

Lianja
llSuccess = .F.

// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.

loHttp = createobject("CkHttp")

// 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

loHttp.SetRequestHeader("Authorization","Token token=abc1234")

loSbResponseBody = createobject("CkStringBuilder")
llSuccess = loHttp.QuickGetSb("https://api.callrail.com/v3/a/{account_id}/calls/{call_id}/recording.json",loSbResponseBody)
if (llSuccess = .F.) then
    ? loHttp.LastErrorText
    release loHttp
    release loSbResponseBody
    return
endif

loJResp = createobject("CkJsonObject")
loJResp.LoadSb(loSbResponseBody)
loJResp.EmitCompact = .F.

? "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
    return
endif

// Sample JSON response:

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

lcUrl = loJResp.StringOf("url")

// Download to a .mp3 file
llSuccess = loHttp.Download(lcUrl,"call_recordings/CAL11df32690b7d46123456789123456789.mp3")
if (llSuccess = .F.) then
    ? loHttp.LastErrorText
else
    ? "success."
endif



release loHttp
release loSbResponseBody
release loJResp