本文档介绍如何发送已获批准的包含一次性密码按钮的身份验证模板。
使用 WhatsApp Business 电话号码 > 消息端点发送包含一次性密码按钮的身份验证模板消息。
POST /<WHATSAPP_BUSINESS_PHONE_NUMBER_ID>/messages
{ "messaging_product": "whatsapp", "recipient_type": "individual", "to": "<CUSTOMER_PHONE_NUMBER>", "type": "template", "template": { "name": "<TEMPLATE_NAME>", "language": { "code": "<TEMPLATE_LANGUAGE_CODE>" }, "components": [ { "type": "body", "parameters": [ { "type": "text", "text": "<ONE-TIME PASSWORD>" } ] }, { "type": "button", "sub_type": "url", "index": "0", "parameters": [ { "type": "text", "text": "<ONE-TIME PASSWORD>" } ] } ] } }
占位符 | 描述 | 值示例 |
---|---|---|
| 客户的 WhatsApp 电话号码。 |
|
| 要向客户发送的一次性密码或验证码。 请注意,此值必须在负载中出现 2 次。 不超过 15 个字符。 |
|
| 模板的语言和区域代码。 |
|
| 模板的名称。 |
|
若请求成功,此 API 将在响应中提供以下内容:
{ "messaging_product": "whatsapp", "contacts": [ { "input": "<INPUT>", "wa_id": "<WA_ID>" } ], "messages": [ { "id": "<ID>" } ] }
占位符 | 描述 | 值示例 |
---|---|---|
字符串 | 接收消息的客户的电话号码。值可能与 |
|
字符串 | 接收消息的客户的 WhatsApp 编号。值可能与 |
|
字符串 | WhatsApp 消息编号。您可以使用“wamid.”后列出的编号来追踪消息状态。 |
|
curl -L 'https://graph.facebook.com/v19.0
/105954558954427/messages' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer EAAJB...' \
-d '{
"messaging_product": "whatsapp",
"recipient_type": "individual",
"to": "12015553931",
"type": "template",
"template": {
"name": "verification_code",
"language": {
"code": "en_US"
},
"components": [
{
"type": "body",
"parameters": [
{
"type": "text",
"text": "J$FpnYnP"
}
]
},
{
"type": "button",
"sub_type": "url",
"index": "0",
"parameters": [
{
"type": "text",
"text": "J$FpnYnP"
}
]
}
]
}
}'
{ "messaging_product": "whatsapp", "contacts": [ { "input": "12015553931", "wa_id": "12015553931" } ], "messages": [ { "id": "wamid.HBgLMTY1MDM4Nzk0MzkVAgARGBI4Qzc5QkNGNTc5NTMyMDU5QzEA" } ] }