繁体   English   中英

移动网站“WhatsApp”按钮可向特定号码发送消息

[英]Mobile website “WhatsApp” button to send message to a specific number

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

<a href="whatsapp://send?text=Hello%20World!">Hello, world!</a>

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

<a href="tel:0123456789">Call</a>

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

将 WhatsApp 消息发送到特定号码的格式(2018 年 11 月更新)

<a href="https://wa.me/whatsappphonenumber/?text=urlencodedtext"></a>

在哪里

whatsappphonenumber是国际格式的完整电话号码

urlencodedtext是 URL 编码的预填充消息。


例子:

  1. 创建一个带有预填充消息的链接,该消息将自动出现在聊天的文本字段中,发送到特定号码

    发送我对您出售的汽车感兴趣+001-(555)1234567

    https://wa.me/15551234567?text=I%20am%20interested%20in%20your%20car%20for%20sale

    笔记 :

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

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

  2. 创建一个仅包含预填充消息的链接,该消息将自动出现在聊天的文本字段中,用户将选择数字

    发送我正在查询公寓列表

    https://wa.me/?text=I%20am%20enquiring%20about%20the%20apartment%20listing

    单击链接后,用户将看到他们可以向其发送预填充消息的联系人列表。

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

——

PS:旧格式(更新前)供参考

<a href="https://api.whatsapp.com/send?phone=whatsappphonenumber&text=urlencodedtext"></a>

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

在安卓上,你可以试试

href="intent://send/[countrycode_without_plus][number]#Intent;scheme=smsto;package=com.whatsapp;action=android.intent.action.SENDTO;end

[countrycode_without_plus][number]替换[countrycode_without_plus][number]

不幸的是,没有选项可以在 whatsapp 协议中输入号码。 仅可使用参数 ABID(地址簿 ID),但您必须让此联系人具有特定名称才能执行此操作。 检查WhatsApp 文档

这个答案对于想要点击网站中的 whatsapp 聊天以使用默认内容或消息重定向 web.whatsapp.com 以及在移动设备中以在移动应用程序中的 whatsapp 中打开并使用默认内容到应用程序中的文本栏的人很有用。

还添加 jquery 链接。

<a  target="_blank" title="Contact Us On WhatsApp" href="https://web.whatsapp.com/send?phone=+91xxxxxxxxx&amp;text=Hi, I would like to get more information.." class="whatsapplink hidemobile" style="background-color:#2DC100">
<i class="fa fa-fw fa-whatsapp" style="color:#fff"></i>
<span style="color:#fff">
    Contact Us On WhatsApp        </span>
</a>
<a  target="_blank" title="Contact Us On WhatsApp" href="https://api.whatsapp.com/send?phone=+91xxxxxxxxx&text=Hi,%20I%20would%20like%20to%20get%20more%20information.." class="whatsapplink hideweb" style="background-color:#2DC100">
<i class="fa fa-fw fa-whatsapp" style="color:#fff"></i>
<span style="color:#fff">
    Contact Us On WhatsApp        </span>
</a>

<script type="text/javascript"> 
var mobile = (/iphone|ipod|android|blackberry|mini|windows\sce|palm/i.test(navigator.userAgent.toLowerCase()));  
if (mobile) { 

$('.hidemobile').css('display', 'none'); // OR you can use $('.hidemobile').hide();
} 
else 
{ 
$('.hideweb').css('display', 'none'); // OR you can use $('.hideweb').hide();
}
</script>

我使用了这个代码,它对我来说很好用,只需将+92xxxxxxxxxx更改为您的有效 whatsapp 号码,并带有国家/地区代码

<script type="text/javascript">
        (function () {
            var options = {
                whatsapp: "+92xxxxxxxxxx", // WhatsApp number
                call_to_action: "Message us", // Call to action
                position: "right", // Position may be 'right' or 'left'

            };
            var proto = document.location.protocol, host = "whatshelp.io", url = proto + "//static." + host;
            var s = document.createElement('script'); s.type = 'text/javascript'; s.async = true; s.src = url + '/widget-send-button/js/init.js';
            s.onload = function () { WhWidgetSendButton.init(host, proto, options); };
            var x = document.getElementsByTagName('script')[0]; x.parentNode.insertBefore(s, x);
        })();
    </script> 

正如其他人所指出的,官方文档可在此处获得: WhatsApp.com 常见问题解答:Android -> Chats -> How to use click to chat 该文件指出:

示例: https ://wa.me/15551234567?text = I 'm%20interested%20in%20your%20car%20for%20sale

但! 我们为什么不尝试将其复制到浏览器中的新选项卡中,然后立即前往那里?

https://wa.me/text=testtesttesttest

结果:找不到错误页面。

是什么赋予了???

通过使用这些格式之一来解决它:

https://api.whatsapp.com/send?text=YourShareTextHere
https://api.whatsapp.com/send?text=YourShareTextHere&phone=123

此 URL 中没有 wa.me 域!

WhatsApp 发送文本页面。

要从网站发送 Whatsapp 消息,请使用以下 URL。

网址: https : //api.whatsapp.com/send?phone=XXXXX&text=dummy

这里的电话文本是参数,其中之一是必需的。

  • 电话:我们需要向谁发送消息
  • text : 需要分享的文字。

也可以使用此 URL。 如果没有找到应用程序,它会显示一个空白屏幕!

网址:whatsapp://send?text=分享的文字!

注意:只有安装了 WhatsApp 桌面应用程序,以上所有内容都可以在网络上使用

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM