Rust
Rust
WhatsApp Cloud API Send Message
See more WhatsApp Examples
Demonstrates how to send a message using the WhatsApp Cloud API (Business App)Chilkat Rust Downloads
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
let http = chilkat::Http::new();
// The following JSON is sent in the request body.
// {
// "messaging_product": "whatsapp",
// "to": "16302581871",
// "type": "template",
// "template": {
// "name": "hello_world",
// "language": {
// "code": "en_US"
// }
// }
// }
let json = chilkat::JsonObject::new();
let _ = json.update_string("messaging_product", "whatsapp");
let _ = json.update_string("to", "15555555555");
let _ = json.update_string("type", "template");
let _ = json.update_string("template.name", "hello_world");
let _ = json.update_string("template.language.code", "en_US");
http.set_auth_token("EAANrS5....yFB9Ma");
http.set_request_header("Content-Type", "application/json");
let resp = chilkat::HttpResponse::new();
if http.http_json("POST", "https://graph.facebook.com/v18.0/111111111111111/messages", &json, "application/json", &resp).is_err() {
println!("{}", http.last_error_text());
return;
}
println!("{}", resp.status_code());
println!("{}", resp.body_str());
// Here's a screenshot of our WhatsApp test app.
//