Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
1.16/5 (4 votes)
See more:
I want to check given mobile number using whatsapp or not. I'm Using VB.NET
Please help Me.

What I have tried:

I don't have any idea how to check the whatsapp number.
Posted
Updated 3-May-23 11:17am

 
Share this answer
 
Comments
Thisara88 21-Oct-22 10:12am    
There haven't any code for VB.net
CHill60 21-Oct-22 10:33am    
There is plenty of information available through that link for you to write your own VB.net code to do this - this is not a code writing service
Here is a VB.NET code snippet to determine the availability of Whatsapp by phone number.
The checker_data.json file specifies the token to work with whapi.cloud, and the number to check.

VB
<pre>Imports System.Net.Http
Imports Newtonsoft.Json.Linq 'You need to install the Newtonsoft.Json package via NuGet

Module Program
    Sub Main()
        Dim dataFile = JObject.Parse(IO.File.ReadAllText("checker_data.json"))
        Dim phone As String = dataFile("phone").ToString()
        Dim token As String = dataFile("token").ToString()

        If String.IsNullOrEmpty(phone) Then
            Console.WriteLine("Phone is empty")
            Return
        End If

        If String.IsNullOrEmpty(token) Then
            Console.WriteLine("Token is empty")
            Return
        End If

        Dim client As New HttpClient()

        client.DefaultRequestHeaders.Add("accept", "application/json")
        client.DefaultRequestHeaders.Add("content-type", "application/json")
        client.DefaultRequestHeaders.Add("authorization", $"Bearer {token}")

        Dim payload As New JObject(
            New JProperty("blocking", "no_wait"),
            New JProperty("force_check", False),
            New JProperty("contacts", New JArray(phone))
        )

        Dim response As HttpResponseMessage = client.PostAsync("https://gate.whapi.cloud/contacts", New StringContent(payload.ToString(), Text.Encoding.UTF8, "application/json")).Result

        If response.IsSuccessStatusCode Then
            Dim jsonResponse = JObject.Parse(response.Content.ReadAsStringAsync().Result)
            Dim contacts = jsonResponse("contacts")

            If contacts IsNot Nothing AndAlso contacts.Count > 0 Then
                Dim status = contacts(0)("status").ToString()
                If status = "valid" Then
                    Console.WriteLine("Phone exists")
                Else
                    Console.WriteLine("Phone doesn't exist")
                End If
            Else
                Console.WriteLine("Check your checker_data file")
            End If
        Else
            Console.WriteLine($"Failed to check. Status Code: {response.StatusCode}")
        End If
    End Sub
End Module


Other methods for automation can be found in whatsapp API documentation: WhatsApp API Documentation | Gateway for developers[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900