Html 特定whatsapp联系人的网络链接
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/30344476/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Web link to specific whatsapp contact
提问by Benny Powers
I'd like to place a link on a webpage which opens a whatsapp chat with a certain whatsapp contact. In other words: I want a "contact me by whatsapp" link to go next to the page's "Contact us my facebook/twitter/google+/etc" links. Something like:
我想在网页上放置一个链接,该链接可打开与某个 whatsapp 联系人的 whatsapp 聊天。换句话说:我想要一个“通过whatsapp联系我”链接到页面的“联系我们我的facebook/twitter/google+/etc”链接旁边。就像是:
href="whatsapp:[email protected]&message="I'd like to chat with you"
回答by Rafael Araújo
I've tried many approaches and I have a winner(see Test 3), here is the result of each one:
我尝试了很多方法,我有一个赢家(见测试 3),这是每个方法的结果:
(I think the Test 3 will also work for you because if the person visiting your site doesn't have you on their contact list, it's the only option that will allow it.)
(我认为测试 3 也适用于您,因为如果访问您网站的人的联系人列表中没有您,这是唯一允许这样做的选项。)
In all tests, the number had to be complete, with country and location code without any initial zeros. Example:
在所有测试中,号码必须是完整的,国家和地区代码没有任何开头的零。例子:
- +55(011) 99999-9999 (NOT)
- +5511999999999 (YES)
- +55(011) 99999-9999 (非)
- +5511999999999(是)
On tests 1 and 2, it only worked with a plus sign on the country code: +5511999999999
在测试 1 和 2 中,它仅与国家代码上的加号一起使用:+5511999999999
Test 1:
测试 1:
<a href="whatsapp://send?abid=phonenumber&text=Hello%2C%20World!">Send Message</a>
This way you must have the phonenumberon your contact list. It doesn't work for me because I wanted to be able to send a message to a number which I may not have on my contact list.
这样,您的联系人列表中必须有电话号码。它对我不起作用,因为我希望能够向我的联系人列表中可能没有的号码发送消息。
If you don't have the number on your contact list, it opens the Whatsapp listing all your registered contacts, so you can choose one.
如果您的联系人列表中没有该号码,它会打开 Whatsapp,列出您注册的所有联系人,您可以从中选择一个。
It's a good option for sharing stuff.
这是分享东西的好选择。
Test 2:
测试 2:
<a href="intent://send/phonenumber#Intent;scheme=smsto;package=com.whatsapp;action=android.intent.action.SENDTO;end">Send Message</a>
This approach only works on Android ANDif you have the number on your contact list. If you don't have it, Android opens your SMS app, so you can invite the contact to use Whatsapp.
此方法仅适用于 Android并且如果您的联系人列表中有该号码。如果您没有,Android 会打开您的 SMS 应用程序,因此您可以邀请联系人使用 Whatsapp。
Test 3 (The Winner):
测试 3 (获胜者):
<a href="https://api.whatsapp.com/send?phone=15551234567">Send Message</a>
This was the only way that worked fully for me.
这是唯一对我有效的方法。
- It works on Android, iOS and Web app on the desktop,
- You can start a conversation with a number that you don't have on your contact list
- 它适用于桌面上的 Android、iOS 和 Web 应用程序,
- 您可以使用您的联系人列表中没有的号码开始对话
And if you wish to have a bookmarklet for additional ease of use, you may use this one:
如果您希望有一个书签以增加易用性,您可以使用这个:
javascript: (function() { var val= prompt("Enter phone number",""); if (val) location="https://api.whatsapp.com/send?phone="+escape('972' + val)+""; })()
javascript: (function() { var val= prompt("Enter phone number",""); if (val) location="https://api.whatsapp.com/send?phone="+escape('972' + val)+""; })()
Youll need to change the country code(or remove it) to you.r target country and paste it in the address field in a chrome/firefox link
您需要将国家/地区代码(或将其删除)更改为 you.r 目标国家/地区并将其粘贴到 chrome/firefox 链接的地址字段中
Worth notice:
值得注意的是:
- I had to update my WhatsApp to the latest version
- The number's country code must not have a leading plus
- More details here: https://www.whatsapp.com/faq/en/general/26000030
- 我不得不将我的 WhatsApp 更新到最新版本
- 号码的国家/地区代码不能有前导加号
- 更多详情:https: //www.whatsapp.com/faq/en/general/26000030
回答by Sachin Doshi
The following link seems to work fine -
以下链接似乎工作正常 -
<a href="whatsapp://send?text=Hello World!&phone=+9198********1">Ping me on WhatsApp</a>
It opens the contact in WhatsApp app, along with the message 'Hello World!' prepopulated in the input text box.
它会在 WhatsApp 应用程序中打开联系人,并显示“Hello World!”消息。预填充在输入文本框中。
(Tested this with google chrome on an android phone.)
(在安卓手机上用谷歌浏览器测试过这个。)
回答by Shemeer M Ali
Official WhatsApp doc Says-:
官方 WhatsApp 文档说-:
https://api.whatsapp.com/send?phone=countrycode+phonenumber
https://api.whatsapp.com/send?phone=countrycode+phonenumber
Use:https://api.whatsapp.com/send?phone=15551234567
使用:https : //api.whatsapp.com/send?phone=15551234567
Don't use:https://api.whatsapp.com/send?phone=+001-(555)1234567
不要使用:https : //api.whatsapp.com/send?phone=+001-(555)1234567
回答by yoshiMannaert
I've tried this:
我试过这个:
<a href="whatsapp://send?abid=phonenumber&text=Hello%2C%20World!">whatsapp</a>
changing 'phonenumber' into a specific phonenumber. This doesn't work completely, but when they click on the link it does open whatsapp and if they click on a contact the message is filled in.
将“电话号码”更改为特定的电话号码。这并不完全有效,但是当他们单击链接时,它会打开 whatsapp,如果他们单击联系人,则会填充消息。
If you want to open a specific person in chat you can, but without text filled in.
如果你想在聊天中打开一个特定的人,你可以,但没有填写文本。
<a href="intent://send/phonenumber#Intent;scheme=smsto;package=com.whatsapp;action=android.intent.action.SENDTO;end">test</a>
You'll probably have to make a choice between the two.
您可能不得不在两者之间做出选择。
some links to help you Sharing link on WhatsApp from mobile website (not application) for Androidhttps://www.whatsapp.com/faq/nl/android/28000012
一些链接可以帮助您 从 Android 的移动网站(不是应用程序)在 WhatsApp 上分享链接https://www.whatsapp.com/faq/nl/android/28000012
Hope this helps
希望这可以帮助
(I tested this with google chrome on an android phone)
(我在安卓手机上用谷歌浏览器测试了这个)
回答by Shri
You can now use a very simple API https://wa.me/
to perform this task where you can provide a valid whatsapp contact number like 15555555555 ( add country code, remove all '+', '-', brackets, spaces or leading zeros). You can also provide a urlencoded text as a predefined msg which user can send directly or change before sending.
您现在可以使用一个非常简单的 APIhttps://wa.me/
来执行此任务,您可以在其中提供有效的 whatsapp 联系电话,例如 15555555555(添加国家/地区代码,删除所有“+”、“-”、方括号、空格或前导零)。您还可以提供 urlencoded 文本作为预定义的 msg,用户可以直接发送或在发送前更改。
Chat with me link: <a href="https://wa.me/15555555555">Contact me by whatsapp</a>
跟我聊天链接:<a href="https://wa.me/15555555555">Contact me by whatsapp</a>
Chat with me link with predefined text: <a href="https://wa.me/15555555555?text=I%27d%20like%20to%20chat%20with%20you">Contact me on whatsapp</a>
与我聊天链接与预定义的文本:<a href="https://wa.me/15555555555?text=I%27d%20like%20to%20chat%20with%20you">Contact me on whatsapp</a>
Beauty of this wa.me
url is you don't need to check user agent as it works on both mobile and desktop (opens web.whatsapp.com)
这个wa.me
网址的美妙之处在于你不需要检查用户代理,因为它适用于移动和桌面(打开 web.whatsapp.com)
Source : https://faq.whatsapp.com/en/general/26000030
来源:https: //faq.whatsapp.com/en/general/26000030
More details in my answer on a similar question https://stackoverflow.com/a/51854282/2485420
我对类似问题的回答中的更多详细信息https://stackoverflow.com/a/51854282/2485420
回答by tribulant
You can use the following URL as per the WhatsApp FAQ:
您可以根据 WhatsApp 常见问题使用以下 URL:
https://wa.me/PHONENUMBERHERE
https://wa.me/PHONENUMBERHERE
Add the country code in front of the number and don't add any plus (+) sign or any dashes (-) or any other characters in the number. Only integrers/numeric values.
在号码前添加国家/地区代码,不要在号码中添加任何加号 (+) 或任何破折号 (-) 或任何其他字符。只有积分器/数值。
You can also predefine a text message to start with:
您还可以预定义一条短信开头:
https://wa.me/PHONENUMBERHERE/?text=urlencodedtext
https://wa.me/PHONENUMBERHERE/?text=urlencodedtext
回答by Trophy Developers U CO. Ltd
This approach only works on Android AND if you have the number on your contactlist. If you don't have it, Android opens your SMS app, so you can invite the contact to use Whatsapp.
此方法仅适用于 Android 并且如果您的联系人列表中有该号码。如果您没有,Android 会打开您的 SMS 应用程序,因此您可以邀请联系人使用 Whatsapp。
<a href="https://api.whatsapp.com/send?phone=2567xxxxxxxxx" method="get" target="_blank"><i class="fa fa-whatsapp"></i></a>
Google Chrome am targeting a blank window
谷歌浏览器的目标是一个空白窗口
回答by Kevin
For what its worth, as of this writing (Nov. 29, 2018), the updated API that seems to work on my end is using this link:
就其价值而言,在撰写本文时(2018 年 11 月 29 日),似乎对我有用的更新 API 正在使用以下链接:
https://wa.me/<phone number here>
Note:
笔记:
Just replace the placeholder <phone number here>
with the intended phone number that you want to use INCLUDINGthe country code, this means I had to add +60
then the rest of the remaining number.
只需将占位符替换为<phone number here>
您要使用的预期电话号码,包括国家/地区代码,这意味着我必须添加+60
其余号码。
It doesn't work on my end without one (using Android and iOS at least). It doesn't work means an error message that says along the lines of "you don't have this number".
如果没有(至少使用 Android 和 iOS),它就无法在我的一端工作。它不起作用意味着一条错误消息说“你没有这个号码”。
Reference:
参考:
回答by iFadi
From the Official Whatsapp FAQ: https://faq.whatsapp.com/en/android/26000030/
来自官方 Whatsapp 常见问题解答:https://faq.whatsapp.com/en/android/26000030/
WhatsApp's Click to Chat feature allows you to begin a chat with someone without having their phone number saved in your phone's address book. As long as you know this person's phone number, you can create a link that will allow you to start a chat with them. By clicking the link, a chat with the person automatically opens. Click to Chat works on both your phone and WhatsApp Web.
WhatsApp 的“点击聊天”功能允许您开始与某人聊天,而无需将他们的电话号码保存在您手机的通讯录中。只要您知道此人的电话号码,您就可以创建一个链接,让您可以与他们开始聊天。通过单击该链接,会自动打开与此人的聊天。单击聊天适用于您的手机和 WhatsApp 网页版。
To create your own link, use https://wa.me/where the is a full phone number in international format. Omit any zeroes, brackets or dashes when adding the phone number in international format. For a detailed explanation on international numbers, read this article. Please keep in mind that this phone number must have an active account on WhatsApp.
要创建您自己的链接,请使用https://wa.me/,其中 是国际格式的完整电话号码。添加国际格式的电话号码时,请省略任何零、括号或破折号。有关国际号码的详细说明,请阅读本文。请记住,此电话号码必须在 WhatsApp 上拥有有效帐户。
Use: https://wa.me/15551234567
Don't use: https://wa.me/+001-(555)1234567
回答by yab86
I tried all combination for swiss numbers on my webpage. Below my results:
我在我的网页上尝试了瑞士数字的所有组合。在我的结果下面:
Doesn't work for Android and iOS
不适用于 Android 和 iOS
https://wa.me/0790000000/?text=myText
Works for iOS but doesn't work for Android
适用于 iOS 但不适用于 Android
https://wa.me/0041790000000/?text=myText
https://wa.me/+41790000000/?text=myText
Works for Android and iOS:
适用于 Android 和 iOS:
https://wa.me/41790000000/?text=myText
https://wa.me/041790000000/?text=myText
Hope this information helps somebody!
希望这些信息对某人有帮助!