我开发了一个网站,主要用在手机上。 我想让用户直接从网页分享信息到WhatsApp。

使用UserAgent检测,我可以区分Android和iOS。 我发现,为了在iOS中实现上述功能,我可以使用URL:

href="whatsapp://send?text=http://www.example.com"

我仍然在寻找当操作系统是Android时使用的解决方案(因为上面的不工作)。 我猜这在某种程度上与在Android中使用“意图”有关,但我不知道如何将其作为href的参数。


当前回答

官方医生说要用wa.me。不要用wa.me。我为这些结果的长度道歉,但这是一个迅速发展的问题....

2020年4月

分享链接

这个链接不正确。关闭此窗口并尝试不同的链接。

2020年5月

分享链接GitHub门票:WhatsApp短链接没有电话号码不再工作

我们找不到你要找的那一页 看来你在找一个根本不存在的页面。或者是我们刚刚删除的页面。无论哪种方式,返回或确保检查url,你的拼写和再试一次。

2020年8月

分享链接

正如预期的那样!

最新消息- 2020年10月结果

分享链接

(又坏了!)og:使用wa.me时禁用图像标签预览。

根据我所看到的一些评论,这似乎仍然是一个间歇性的问题,因此,今后,我建议您坚持使用api.whatsapp.com URL!

如果你想分享,你必须使用以下两种URL格式之一:

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

其他回答

恐怕Android版WhatsApp目前不支持从web浏览器调用。

我现在的项目也有同样的要求,因为我找不到任何合适的信息,所以我最终下载了APK文件。

在Android中,如果一个应用程序想要从web浏览器中被调用,它需要定义一个带有类别Android .intent.category. browsable的Activity。

你可以在这里找到更多信息:https://developers.google.com/chrome/mobile/docs/intents

如果你看一下WhatsApp的AndroidManifest.xml文件,唯一的活动类别BROWSABLE是这个:

<activity android:name="com.whatsapp.Conversation"   android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" android:windowSoftInputMode="stateUnchanged">
        <intent-filter>
            <action android:name="android.intent.action.SENDTO" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
            <data android:scheme="sms" />
            <data android:scheme="smsto" />
        </intent-filter>
    </activity>

我已经玩了一段时间了,但我不能让它工作。我最多只能从Chrome浏览器打开WhatsApp应用程序,但我不知道如何设置消息内容和收件人。

由于WhatsApp团队没有记录,我认为这项工作仍在进行中。看起来未来WhatsApp也会提供短信服务。

获得更多信息的唯一方法是联系WhatsApp的开发团队,我试过了,但我仍在等待回复。

的问候!

官方医生说要用wa.me。不要用wa.me。我为这些结果的长度道歉,但这是一个迅速发展的问题....

2020年4月

分享链接

这个链接不正确。关闭此窗口并尝试不同的链接。

2020年5月

分享链接GitHub门票:WhatsApp短链接没有电话号码不再工作

我们找不到你要找的那一页 看来你在找一个根本不存在的页面。或者是我们刚刚删除的页面。无论哪种方式,返回或确保检查url,你的拼写和再试一次。

2020年8月

分享链接

正如预期的那样!

最新消息- 2020年10月结果

分享链接

(又坏了!)og:使用wa.me时禁用图像标签预览。

根据我所看到的一些评论,这似乎仍然是一个间歇性的问题,因此,今后,我建议您坚持使用api.whatsapp.com URL!

如果你想分享,你必须使用以下两种URL格式之一:

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

最新更新

现在您可以使用来自whatsapp https://wa.me/的最新API,而无需担心用户代理,API将执行用户代理处理。

在各自的whatsapp客户端(Android / iOS / Webapp)中共享带有联系人选择选项的预填充文本:

https://wa.me/?text=urlencodedtext

在各自的whatsapp客户端(Android / iOS / Webapp)中打开特定whatsapp用户的聊天对话框:

https://wa.me/whatsappphonenumber

与特定用户共享预填充文本(结合以上两个):

https://wa.me/whatsappphonenumber/?text=urlencodedtext

注意:whatsappphonenumber应该是国际格式的完整电话号码。在添加国际格式的电话号码时,请省略任何零、括号或破折号。

官方文件请访问https://faq.whatsapp.com/en/general/26000030

试着这样做:

<a href="https://wa.me/(phone)?text=(text URL encoded)">Link</a>

甚至你可以发送消息而不需要在链接中输入电话号码:

<a href="https://wa.me/?text=Hello%20world!">Say hello</a>

点击链接后,您将看到一个联系人列表,您可以将消息发送给这些联系人。

更多信息请访问https://faq.whatsapp.com/en/general/26000030。

好运!

上面的答案有点过时了。虽然这些方法工作,但通过使用下面的方法,您可以将任何文本共享到一个预定义的数字。下面的方法适用于android, WhatsApp web, IOS等。

你只需要使用下面的格式:

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

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

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

Use: https://wa.me/15551234567 Don't use: 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. Example: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 Example: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.

欲了解更多信息,请参见https://www.whatsapp.com/faq/en/general/26000030