移动网站"WhatsApp"按钮将消息发送到特定号码

LyR*_*yRo 26 html mobile-website whatsapp

可以定制移动网站以允许用户在WhatsApp中将预先填写的消息共享给手动选择的联系人.这里给出的是使用自定义URL方案完成的.一个例子:

<a href="whatsapp://send?text=Hello%20World!">Hello, world!</a>
Run Code Online (Sandbox Code Playgroud)

要拨打特定号码,我们使用:

<a href="tel:0123456789">Call</a>
Run Code Online (Sandbox Code Playgroud)

同样,我们可以将WhatsApp消息发送到特定号码(或者至少打开聊天),而无需用户手动选择电话号码,而是将其作为预定义参数/属性值之一吗?

ad0*_*d08 34

现在可以轻松完成!你只需要使用这种格式:

<a href="https://api.whatsapp.com/send?phone=whatsappphonenumber&text=urlencodedtext"></a>
Run Code Online (Sandbox Code Playgroud)

更新 - 从现在开始使用(2018年11月)

<a href="https://wa.me/whatsappphonenumber/?text=urlencodedtext"></a>
Run Code Online (Sandbox Code Playgroud)

使用:https://wa.me/15551234567

不要使用:https://wa.me/+001-(555)1234567

要使用预先填充的消息创建自己的链接,该消息将自动显示在聊天的文本字段中,请使用 https://wa.me/whatsappphonenumber/?text=urlencodedtext其中whatsappphonenumber是国际格式和URL的完整电话号码-encodedtext是URL编码的预填充消息.

示例:https://wa.me/15551234567?text =我%20感兴趣%20in%20your%20car%20for%20sale

要使用预填充消息创建链接,请使用 https://wa.me/?text=urlencodedtext

示例:https://wa.me/?text =我%20inquiring%20about%20the%20apartment%20listing

点击该链接后,您将看到一个可以发送邮件的联系人列表.

有关更多信息,请参阅https://www.whatsapp.com/faq/en/general/26000030

  • 根据文档,现在正确的链接是:```https://wa.me/&lt;number&gt;``` (2认同)

小智 9

在android上,你可以试试

href="intent://send/[countrycode_without_plus][number]#Intent;scheme=smsto;package=com.whatsapp;action=android.intent.action.SENDTO;end
Run Code Online (Sandbox Code Playgroud)

替换[countrycode_without_plus][number]号码,


Shr*_*hri 7

WhatsApp现在提供了更简单的API。https://wa.me/这没有引入任何新功能,而只是一种简单的执行方式。实施此API时无需检查用户代理,因为它也可与本机应用程序以及桌面上的whatsapp(web.whatsapp.com)的Web界面一起使用。

可以在多个用例中使用

  • A 单击聊天按钮:https://wa.me/whatsappphonenumber用于打开与指定的whatsapp用户的聊天对话框。请注意whatsappphonenumber,,应为国际格式的有效whatsapp数字,且不带前导零,“ +”,“-”和空格。例如15551234567

    <a href="https://wa.me/15551234567">Whatsapp Me</a>

  • A 在whatsapp上共享此按钮: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