Rust Requires Chilkat v11.0.0+
Rust
Clickatell One API: Look up SMS delivery status
See more Clickatell Examples
Use the apiMessageId returned by the One API send example and the same integration key. The ID goes in the URL path. The SMS result contains sms.status and the timestamp of the last status change. For example, QUEUED means processing is pending and DEVICE_ACK indicates a device acknowledgment.
The response can also contain a WhatsApp result or have no identifiable channel for an unknown message. For ongoing delivery updates, configure delivery notifications in the integration. This example performs one lookup.
Chilkat Rust Downloads
let mut success = false;
// Assumes Chilkat is unlocked. See Global Unlock Sample.
let http = chilkat::Http::new();
http.set_require_ssl_cert_verify(true);
// Supply the key for this One API integration from application configuration.
http.set_request_header("Authorization", "ONE_API_KEY");
http.set_request_header("Accept", "application/json");
// Use the provider-generated ID from an accepted One API send.
let _ = http.set_url_var("id", "ONE_API_MESSAGE_ID");
let resp = chilkat::HttpResponse::new();
success = http.http_no_body("GET", "https://platform.clickatell.com/v1/message/{$id}", &resp).is_ok();
if resp.status_code() == 0 {
println!("No HTTP response. Check the connection and retry the lookup.");
return;
}
let reply = chilkat::JsonObject::new();
let parsed = reply.load(&resp.body_str()).is_ok();
if (!success) || ((resp.status_code() != 200)) {
println!("Clickatell returned HTTP {}", resp.status_code());
if parsed {
if reply.has_member("error.description") {
println!("{}", reply.string_of("error.description").unwrap_or_default());
}
}
return;
}
if !parsed {
println!("Expected a JSON response.");
return;
}
// A known SMS has a string status under the sms member.
if reply.json_type_of("sms.status") != 1 {
if reply.json_type_of("whatsapp.status") == 1 {
println!("This message has WhatsApp status: {}", reply.string_of("whatsapp.status").unwrap_or_default());
} else {
println!("No SMS status was returned. Check the message ID and integration.");
if reply.json_type_of("status") == 1 {
println!("Reported status: {}", reply.string_of("status").unwrap_or_default());
}
}
return;
}
println!("SMS status: {}", reply.string_of("sms.status").unwrap_or_default());
if reply.json_type_of("sms.timestamp") == 2 {
// Read the provider timestamp as text to preserve every digit.
println!("Last status change (provider timestamp): {}", reply.string_of("sms.timestamp").unwrap_or_default());
}