Android: 如何以编程方式检查 WhatsApp 上的号码是否在线?

Android: How to programmatically check if a number is online on WhatsApp?

如何以编程方式检查联系人号码在 WhatsApp 上是否在线

我在 Google 上搜索过,我刚找到另一个应用程序,它会在输入的联系电话上线时发出通知,但我想以编程方式知道这一点,以便我可以在我的应用程序中实现它.

注意:- 如果存在这种应用程序,那么一定有解决我的问题的方法。

我在 SO 上发现了另一个问题,但答案与问题中的问题完全无关,而且该答案有 4 个赞成票并被 OP 接受,我不知道如何?

那么,那里有 可用的吗?或任何 Intent 操作?

知道一个帐户的在线状态仍然是私人的API。所以你不能以 "legal" 的方式做到这一点。

当然,WhatsApp 和您提到的其他应用程序可以做到这一点。所以他们知道该怎么做。

如果您想知道它们如何按照您的要求进行操作,则必须对它们进行逆向工程。

您可以知道某个号码是否是有效的 WhatsApp 用户。

根据文档,您必须 Facebook WhatsApp Buisiness API:

https://developers.facebook.com/docs/whatsapp/api/reference/

WhatsApp is a fast, secure, and reliable way for businesses to reach their customers all over the world. This guide describes how businesses can use the WhatsApp Business API to interact with their customers.

This version of the WhatsApp Business API uses a REST API Architecture with JSON data formats. The API follows the standard HTTP request-response exchange.

拥有有效的企业帐户后,您就可以查询 Contacts (Contacts) 节点

Use the contacts node for the following purposes:

To verify that a phone number in your database belongs to a valid WhatsApp account. You must ensure that status is valid before you can message a user. To get the WhatsApp ID for a phone number. WhatsApp IDs are needed to send messages, use notifications, and work with groups.

来自 doc 做这样的 POST 请求:

POST /v1/contacts

{
   "blocking": "wait",
   "contacts": [
      "16315551003",
      "1-631-555-1002",
      "+54 9 11 5612-1008",
      "+1 (516) 283-7151"
   ] 
}

您可以获得这样的信息:

Response After you send the request to check contacts you will receive a response with the current status of the requested numbers. Contacts that are new will typically have a status of processing as the application asynchronously determines if the numbers belong to a valid WhatsApp account.

If you use the "blocking": "wait" option in the request, the response is now synchronous, so the response is generated only once the status of all of the numbers has been determined. This implies that the request will take a longer time to return if there are new contacts, but you will not see the "processing" value returned. The example code below demonstrates this behavior.

{
   "contacts": [
      {
         "input": "1-631-555-1002",
         "status": "invalid"
      },
      {
         "input": "6315551003",
         "status": "valid"
         "wa_id": "16315551003"
      },
      {
         "input": "+54 9 11 5612-1008",
         "status": "invalid"
      },
      {
         "input": "+1 (516) 283-7151",
         "status": "valid"
         "wa_id": "15162837151"
      }
   ]
}