【发布时间】:2020-07-24 16:33:52
【问题描述】:
有一个脚本可以向whatsapp发送消息
<script>
$(document).ready(function() {
// URL for the POST /message request
var url = 'https://eu43.chat-api.com/instance**********/message?token=**********';
var data = {
phone: '***********', // Recipient's phone number
body: 'There should be a message here', // Message
};
// Send a request when the button is clicked
$(".button").click(function() {
$.ajax(url, {
data: JSON.stringify(data),
contentType: 'application/json',
type: 'POST'
});
});
});
</script>
还有一些输入由客户填写,以通过whatsapp中的电话号码将有关订单的信息发送给相关合作伙伴(咖啡馆、餐馆),以便形成和交付订单
<input name="name" class="t-input">
<input name="phone" class="t-input">
<input name="address" class="t-input">
<input type="hidden" name="recipient" value="78888888888"> //Phone number of the recipient of order information in whatsapp
现在的任务是将有关订单的信息发送到whatsapp,该信息包含在输入值(姓名,电话,地址)到收件人的号码(收件人)中,并将名称放在每个输入值之前(收件人除外),即姓名:、电话号码:、地址:换行。收件人值必须插入到电话中,其他输入值(姓名、电话、地址)必须插入到数据中。
收到的消息示例:
- 姓名:亚历克斯
- 电话:+79999999999
- 地址:喀山市鲍马纳街20号房子,19号公寓
- 订购:披萨“玛格丽塔”
【问题讨论】:
标签: javascript jquery ajax input whatsapp