可以定制移动网站以允许用户在WhatsApp中将预先填写的消息共享给手动选择的联系人 . 正如here所述,它是使用自定义URL方案完成的 . 一个例子:
<a href="whatsapp://send?text=Hello%20World!">Hello, world!</a>
要拨打特定号码,我们使用:
<a href="tel:0123456789">Call</a>
同样,我们可以将WhatsApp消息发送到特定号码(或者至少打开聊天),而无需用户手动选择电话号码,而是将其作为预定义参数/属性值之一吗?
7 回答
Official WhatsApp doc Says-:
https://api.whatsapp.com/send?phone=countrycode+phonenumber&text=urlencodedtext
使用:https://api.whatsapp.com/send?phone=15551234567&text=urlencodedtext
不要使用:https://api.whatsapp.com/send?phone=+001-(555)1234567
https://faq.whatsapp.com/en/general/26000030
现在可以轻松完成!你只需要使用这种格式:
更新 - 从现在开始使用(2018年11月)
有关更多信息,请参阅https://www.whatsapp.com/faq/en/general/26000030
在android上,你可以试试
用数字替换
[countrycode_without_plus][number]
,WhatsApp现在提供了一个更简单的API
https://wa.me/
这不是在实现此API时检查用户代理,因为它也可以与本机应用程序以及桌面上的whatsapp(web.whatsapp.com)的Web界面一起使用 .这可以在多个用例中使用
https://wa.me/whatsappphonenumber
打开与指定whatsapp用户的聊天对话框 . 请注意whatsappphonenumber
应该是国际格式的有效whatsapp号码,不带前导零,'+','-'和空格 . 例如15551234567<a href="https://wa.me/15551234567">Whatsapp Me</a>
https://wa.me/?text=urlencodedtext
打开带有预设文本的whatsapp联系人选择对话框 . 例如<a href="https://wa.me/?text=I%20found%20a%20great%20website.%20Check%20out%20this%20link%20https%3A%2F%2Fwww.example.com%2F">Share on WhatsApp</a>
https://wa.me/whatsappphonenumber/?text=urlencodedtext
<a href="https://wa.me/15551234567?text=I%20am%20interested%20in%20your%20services.%20How%20to%20get%20started%3F">I am interested</a>
有关官方文档,请访问https://faq.whatsapp.com/en/general/26000030
不幸的是,没有选择将数字放在whatsapp协议中 . 只能使用参数ABID(地址簿ID),但您必须具有此特定名称的联系人才能执行此操作 . 检查WhatsApp Documentation
这个答案对于那些想要点击聊天网站中的whatsapp以使用默认内容或消息重定向web.whatsapp.com并在移动设备中以在移动应用中使用默认内容打开应用中的文本栏的whatsapp而言非常有用 .
还添加了jquery链接 .
我使用此代码,它适用于我,只需将 +92xxxxxxxxxx 更改为您的有效whatsapp号码,国家代码