Lua
Lua
WhatsApp Cloud API Send Message
See more WhatsApp Examples
Demonstrates how to send a message using the WhatsApp Cloud API (Business App)Chilkat Lua Downloads
local chilkat = require("chilkat")
-- This example requires the Chilkat API to have been previously unlocked.
-- See Global Unlock Sample for sample code.
local 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"
-- }
-- }
-- }
local json = chilkat.JsonObject.new()
json:update_string("messaging_product", "whatsapp")
json:update_string("to", "15555555555")
json:update_string("type", "template")
json:update_string("template.name", "hello_world")
json:update_string("template.language.code", "en_US")
http.auth_token = "EAANrS5....yFB9Ma"
http:set_request_header("Content-Type", "application/json")
local resp = chilkat.HttpResponse.new()
local success = http:http_json("POST", "https://graph.facebook.com/v18.0/111111111111111/messages", json, "application/json", resp)
if not success then
print(http.last_error_text)
return
end
print(resp.status_code)
print(resp.body_str)
-- Here's a screenshot of our WhatsApp test app.
--