Whatsapp URL 架构发送消息到电话号码

Whatsapp URL Schema send message to phonenumber

是否可以向未存储在通讯录中的特定 whatsapp 帐户(phonenumer)发送 whatsapp 消息?

想在我的网站上设置 whatsapp url 方案以通过 whatsapp 提供直接联系。

不可以,如果不将号码存储在通讯录中,就无法使用 WhatsApp 向某人发送消息。这样做的原因正是您想要做的:WhatsApp 不允许您发送随机数 'spam'。您必须收集号码并将其添加到您的联系人,然后手动向他们发送消息。

有可能!尝试使用 swift 3 和 xcode 8.3.2.

    let date = Date()
    let msg = "Hi my dear friends\(date)"
    let urlWhats = "whatsapp://send?phone=phoneNumber&abid=phoneNumber&text=hi"
    if let urlString = urlWhats.addingPercentEncoding(withAllowedCharacters: NSCharacterSet.urlQueryAllowed) {
        if let whatsappURL = NSURL(string: urlString) {
            if UIApplication.shared.canOpenURL(whatsappURL as URL) {
                UIApplication.shared.openURL(whatsappURL as URL)
            } else {
                print("please install watsapp")
            }
        }
    }

可以使用 WhatsApp 点击聊天:https://faq.whatsapp.com/en/android/26000030/

基本上你需要像这样制作一个url:https://wa.me/PHONE_NUMBER?text=TEXT_TO_SEND

工作示例:https://wa.me/514293537789?text=Hello%20this%20is%20an%20automatic%20message

您需要确认输入 link 后 whatsapp 将取消授权的按钮中的消息,这样做是为了避免垃圾邮件。

看看当您使用 WhatsApp 时会发生什么,但不要指明 phone 号码:http://wa.me/?text=mytest。我得到结果:

We couldn't find the page you were looking for

希望这不是您要分享的内容!我强烈建议使用以下格式之一,不带 wa.me 域,但带 api.whatsapp.com 域:

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

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

如果您有兴趣观看跟踪这些 URL 的项目,请查看我们!:https://github.com/bradvin/social-share-urls#whatsapp