首页 文章

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

提问于
浏览
18

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

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

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

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

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

7 回答

  • 2

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

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

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

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

    使用: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%20%20apartment%20listing点击链接后,您将看到一个联系人列表,您可以将消息发送到 .

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

  • 6

    在android上,你可以试试

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

    用数字替换 [countrycode_without_plus][number]

  • 1

    WhatsApp现在提供了一个更简单的API https://wa.me/ 这不是在实现此API时检查用户代理,因为它也可以与本机应用程序以及桌面上的whatsapp(web.whatsapp.com)的Web界面一起使用 .

    这可以在多个用例中使用

    • A Click to chat 按钮:使用 https://wa.me/whatsappphonenumber 打开与指定whatsapp用户的聊天对话框 . 请注意 whatsappphonenumber 应该是国际格式的有效whatsapp号码,不带前导零,'+','-'和空格 . 例如15551234567

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

    • A Share this on 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>

    • 带有 prefilled textContact me 按钮:以上两者的组合,如果您希望从登陆特定页面的用户处获得预先填写的自定义消息,则可能非常有用 . 使用格式 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

  • 17

    不幸的是,没有选择将数字放在whatsapp协议中 . 只能使用参数ABID(地址簿ID),但您必须具有此特定名称的联系人才能执行此操作 . 检查WhatsApp Documentation

  • 0

    这个答案对于那些想要点击聊天网站中的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>
    
  • 1

    我使用此代码,它适用于我,只需将 +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>
    

相关问题