简体   繁体   English

如何将 WhatsApp 分享按钮添加到 PHP 网站?

[英]How to add WhatsApp share button to PHP website?

Below links are using Facebook and other networks to share post以下链接使用 Facebook 和其他网络分享帖子

How to place and link a Whatsapp share button?如何放置和链接 Whatsapp 分享按钮?

<a href="#" class="fa fa-facebook" onclick="OpenShareWindow('https://www.facebook.com/sharer/sharer.php?u={{ENCODED_URL}}')"></a>
               <a href="#" class="fa fa-twitter" onclick="OpenShareWindow('https://twitter.com/home?status={{ENCODED_URL}}')"></a>
               <a href="#" class="fa fa-google" onclick="OpenShareWindow('https://plus.google.com/share?url={{ENCODED_URL}}')"></a>
               <a href="#" class="fa fa-linkedin" onclick="OpenShareWindow('https://www.linkedin.com/shareArticle?mini=true&url={{ENCODED_URL}}&title={{TITLE}}')"></a>
               <a href="#" class="fa fa-pinterest" onclick="OpenShareWindow('https://pinterest.com/pin/create/button/?url={{ENCODED_URL}}&media={{THUMBNAIL}}')"></a>
               <a href="#" class="fa fa-tumblr" onclick="OpenShareWindow('http://www.tumblr.com/share/link?url={{ENCODED_URL}}')"></a>
               <a href="#" class="fa fa-reddit" onclick="OpenShareWindow('http://www.reddit.com/submit?url={{ENCODED_URL}}')"></a>

To create your own link, use https://wa.me/ where the is a full phone number in international format.要创建您自己的链接,请使用https://wa.me/ ,其中 是国际格式的完整电话号码。 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.请记住,此电话号码必须在 WhatsApp 上拥有有效帐户。

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

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

To create your own link with a pre-filled message that will automatically appear in the text field of a chat, use https://wa.me/whatsappphonenumber/?text=urlencodedtext where whatsappphonenumber is a full phone number in international format and URL-encodedtext is the URL-encoded pre-filled message.要使用自动出现在聊天文本字段中的预填充消息创建自己的链接,请使用https://wa.me/whatsappphonenumber/?text=urlencodedtext其中 whatsappphonenumber 是国际格式和 URL 的完整电话号码-encodedtext 是 URL 编码的预填充消息。

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

To create a link with just a pre-filled message, use https://wa.me/?text=urlencodedtext要创建仅包含预填充消息的链接,请使用https://wa.me/?text=urlencodedtext

Example: https://wa.me/?text=I 'm%20inquiring%20about%20the%20apartment%20listing示例: https ://wa.me/?text = I'm%20inquiring%20about%20the%20apartment%20listing

After clicking on the link, you will be shown a list of contacts you can send your message to.单击链接后,您将看到一个联系人列表,您可以向其发送消息。

What is about using a URL Scheme?什么是使用 URL Scheme?

from the WhatsApp Docu : https://faq.whatsapp.com/en/android/28000012来自 WhatsApp 文档: https ://faq.whatsapp.com/en/android/28000012

Custom URL Scheme自定义 URL 方案

WhatsApp provides a custom URL scheme to interact with WhatsApp: WhatsApp 提供了一个自定义 URL 方案来与 WhatsApp 交互:

If you have a website and want to open a WhatsApp chat with a pre-filled message, you can use our custom URL scheme to do so.如果您有一个网站,并希望使用预先填写的消息打开 WhatsApp 聊天,您可以使用我们的自定义 URL 方案来执行此操作。 Opening whatsapp://send?text= followed by the text to send, will open WhatsApp, allow the user to choose a contact, and pre-fill the input field with the specified text.打开 whatsapp://send?text= 后跟要发送的文本,将打开 WhatsApp,允许用户选择联系人,并用指定的文本预填充输入字段。

feel free to add also other messengers ..随意添加其他信使..

Threema:三马:

threema://compose?text=Hello Threema://compose?text=你好

see docu: https://threema.ch/de/faq/url_actions见文档: https : //threema.ch/de/faq/url_actions

Telegram:电报:

tg://msg?text= or tg://msg?text= 或

tg://share?url=www.example.com?t=12&text=Check%20out%20this%20url tg://share?url=www.example.com?t=12&text=Check%20out%20this%20url

First: Official Whatsapp Sharing Documentation .第一:官方Whatsapp共享文档 Take a look at what happens when you use WhatsApp, but don't indicate a phone number: http://wa.me/?text=mytest .看看当您使用 WhatsApp 时会发生什么,但不要指明电话号码: http ://wa.me/?text=mytest。 I get the result:我得到结果:

We couldn't find the page you were looking for我们找不到您要找的页面

Hopefully this is not what you intended to share!希望这不是您要分享的内容! I highly recommend using one of the following formats, without the wa.me domain, but with the api.whatsapp.com domain:我强烈建议使用以下格式之一,不使用wa.me域,但使用api.whatsapp.com域:

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

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

If you are interested in watching a project that keeps track of these URLs, then check us out!: https://github.com/bradvin/social-share-urls#whatsapp如果您有兴趣观看跟踪这些 URL 的项目,请查看我们!: https : //github.com/bradvin/social-share-urls#whatsapp

社交分享 URL

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

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