Rust
Rust
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 Rust Downloads
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
let http = chilkat::Http::new();
// 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
http.set_request_header("Authorization", "Token token=abc1234");
let sb_response_body = chilkat::StringBuilder::new();
if http.quick_get_sb("https://api.callrail.com/v3/a/{account_id}/calls/{call_id}/recording.json", &sb_response_body).is_err() {
println!("{}", http.last_error_text());
return;
}
let j_resp = chilkat::JsonObject::new();
let _ = j_resp.load_sb(&sb_response_body);
j_resp.set_emit_compact(false);
println!("Response Body:");
println!("{}", j_resp.emit().unwrap_or_default());
let resp_status_code = http.last_status();
println!("Response Status Code = {}", resp_status_code);
if resp_status_code >= 400 {
println!("Response Header:");
println!("{}", http.last_header());
println!("Failed.");
return;
}
// Sample JSON response:
// {
// "url": "http://app.callrail.com/calls/CAL11df32690b7d46123456789123456789/recording/redirect?access_key=241sa242sadqwerty123"
// }
let url = j_resp.string_of("url").unwrap_or_default();
// Download to a .mp3 file
if http.download(&url, "call_recordings/CAL11df32690b7d46123456789123456789.mp3").is_err() {
println!("{}", http.last_error_text());
} else {
println!("success.");
}