Javascript 如何在网站中实现whatsapp分享按钮

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/50712618/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-23 04:40:07  来源:igfitidea点击:

How to implements whatsapp share button in website

javascriptphpapi

提问by Faizal Hussain

Im building a website in php , i would like to implement whatsapp share button in it .I searched the internet for a while but couldn't find anything can any one explain how it works and how can i implement

我正在用 php 建立一个网站,我想在其中实现 whatsapp 共享按钮。我在互联网上搜索了一段时间,但找不到任何东西,有人可以解释它是如何工作的,我该如何实现

Thanks in advance

提前致谢

回答by Dhanu K

This might help you

这可能会帮助你

<a href="https://api.whatsapp.com/send?phone=91XXXXXXXXXX&text=urlencodedtext" target="_blank">WA</a>

phone and text parameters are not mandatory

电话和文本参数不是强制性的

this works in the mobile browser and pc browser, in pc this will open https://web.whatsapp.com/

这适用于移动浏览器和电脑浏览器,在电脑中这将打开https://web.whatsapp.com/

I think this might be a better solution.

我认为这可能是一个更好的解决方案。

回答by Akhil Aravind

Please note that this only works with mobile devices and mobile browsers

请注意,这只适用于移动设备和移动浏览器

use this to share in whatsapp, text= The text to share / link / or anything; if you are using url, dont forget to encode it

使用它在whatsapp中分享,文本=分享/链接/或任何内容的文本;如果您使用的是 url,请不要忘记对其进行编码

<a href="whatsapp://send?text=The text to share!" data-action="share/whatsapp/share">Share via Whatsapp</a>