व्हाट्सएप एपीआई द्वारा vbnet का उपयोग करके संदेश कैसे भेजें

परिचय

इस ट्यूटोरियल में, हम vb.net . का उपयोग करके WhatsAppAPI के माध्यम से WhatsApp संदेश भेजने के लिए एक पेज बनाएंगे

Visual Basic.NET का उपयोग करते हुए पहला WhatsApp API संदेश

Imports System 
Imports System.Net
Imports System.Text
Imports System.IO
Imports System.Web

Module base64  
    Sub Main()  
        Dim WebRequest As HttpWebRequest
        Dim instance_id as string ="instance1150"
        Dim token as string  ="1g55hyy7ixrsi2"
        Dim mobile_number as string  ="14155552671"
        dim ultramsgApiUrl as string  ="https://api.ultramsg.com/"+instance_id+"/messages/chat"
        WebRequest = HttpWebRequest.Create(ultramsgApiUrl)
        Dim postdata As String = "token=" + token + "&to="+ mobile_number + "&body=WhatsApp API on UltraMsg.com works good"
        Dim enc As UTF8Encoding = New System.Text.UTF8Encoding()
        Dim postdatabytes As Byte()  = enc.GetBytes(postdata)
        WebRequest.Method = "POST"
        WebRequest.ContentType = "application/x-www-form-urlencoded"
        WebRequest.GetRequestStream().Write(postdatabytes)
       'WebRequest.GetRequestStream().Write(postdatabytes, 0, postdatabytes.Length) 
        Dim ret As New System.IO.StreamReader(WebRequest.GetResponse().GetResponseStream())
        console.writeline(ret.ReadToEnd())
    End Sub  
  
End Module  

vbnet का उपयोग करके छवि भेजें

Imports System 
Imports System.Net
Imports System.Text
Imports System.IO
Imports System.Web

Module base64  
    Sub Main()  
        Dim WebRequest As HttpWebRequest
        Dim instance_id as string ="instance1150"
        Dim token as string  ="1g55hyy7ixrsi2"
        Dim mobile_number as string  ="14155552671"
        dim ultramsgApiUrl as string  ="https://api.ultramsg.com/"+instance_id+"/messages/image"
        WebRequest = HttpWebRequest.Create(ultramsgApiUrl)
        Dim postdata As String = "token=" + token + "&to="+ mobile_number + "&image=https://file-example.s3-accelerate.amazonaws.com/images/test.jpeg&caption=image Caption"
        Dim enc As UTF8Encoding = New System.Text.UTF8Encoding()
        Dim postdatabytes As Byte()  = enc.GetBytes(postdata)
        WebRequest.Method = "POST"
        WebRequest.ContentType = "application/x-www-form-urlencoded"
        WebRequest.GetRequestStream().Write(postdatabytes)
'WebRequest.GetRequestStream().Write(postdatabytes, 0, postdatabytes.Length)
        Dim ret As New System.IO.StreamReader(WebRequest.GetResponse().GetResponseStream())
        console.writeline(ret.ReadToEnd())
    End Sub  
  
End Module  

vbnet का उपयोग करके दस्तावेज़ भेजें

Imports System 
Imports System.Net
Imports System.Text
Imports System.IO
Imports System.Web

Module base64  
    Sub Main()  
        Dim WebRequest As HttpWebRequest
        Dim instance_id as string ="instance1150"
        Dim token as string  ="1g55hyy7ixrsi2"
        Dim mobile_number as string  ="14155552671"
        dim ultramsgApiUrl as string  ="https://api.ultramsg.com/"+instance_id+"/messages/document"
        WebRequest = HttpWebRequest.Create(ultramsgApiUrl)
        Dim postdata As String = "token=" + token + "&to="+ mobile_number + "&filename=hello.pdf&document=https://file-example.s3-accelerate.amazonaws.com/documents/cv.pdf"
        Dim enc As UTF8Encoding = New System.Text.UTF8Encoding()
        Dim postdatabytes As Byte()  = enc.GetBytes(postdata)
        WebRequest.Method = "POST"
        WebRequest.ContentType = "application/x-www-form-urlencoded"
        WebRequest.GetRequestStream().Write(postdatabytes)
'WebRequest.GetRequestStream().Write(postdatabytes, 0, postdatabytes.Length)
        Dim ret As New System.IO.StreamReader(WebRequest.GetResponse().GetResponseStream())
        console.writeline(ret.ReadToEnd())
    End Sub  
  
End Module  

vbnet का उपयोग करके ऑडियो भेजें

Imports System 
Imports System.Net
Imports System.Text
Imports System.IO
Imports System.Web

Module base64  
    Sub Main()  
        Dim WebRequest As HttpWebRequest
        Dim instance_id as string ="instance1150"
        Dim token as string  ="1g55hyy7ixrsi2"
        Dim mobile_number as string  ="14155552671"
        dim ultramsgApiUrl as string  ="https://api.ultramsg.com/"+instance_id+"/messages/audio"
        WebRequest = HttpWebRequest.Create(ultramsgApiUrl)
        Dim postdata As String = "token=" + token + "&to="+ mobile_number + "&audio=https://file-example.s3-accelerate.amazonaws.com/audio/2.mp3"
        Dim enc As UTF8Encoding = New System.Text.UTF8Encoding()
        Dim postdatabytes As Byte()  = enc.GetBytes(postdata)
        WebRequest.Method = "POST"
        WebRequest.ContentType = "application/x-www-form-urlencoded"
        WebRequest.GetRequestStream().Write(postdatabytes)
'WebRequest.GetRequestStream().Write(postdatabytes, 0, postdatabytes.Length)
        Dim ret As New System.IO.StreamReader(WebRequest.GetResponse().GetResponseStream())
        console.writeline(ret.ReadToEnd())
    End Sub  
  
End Module  

vbnet . का उपयोग करके आवाज भेजें

Imports System 
Imports System.Net
Imports System.Text
Imports System.IO
Imports System.Web

Module base64  
    Sub Main()  
        Dim WebRequest As HttpWebRequest
        Dim instance_id as string ="instance1150"
        Dim token as string  ="1g55hyy7ixrsi2"
        Dim mobile_number as string  ="14155552671"
        dim ultramsgApiUrl as string  ="https://api.ultramsg.com/"+instance_id+"/messages/voice"
        WebRequest = HttpWebRequest.Create(ultramsgApiUrl)
        Dim postdata As String = "token=" + token + "&to="+ mobile_number + "&audio=https://file-example.s3-accelerate.amazonaws.com/voice/oog_example.ogg"
        Dim enc As UTF8Encoding = New System.Text.UTF8Encoding()
        Dim postdatabytes As Byte()  = enc.GetBytes(postdata)
        WebRequest.Method = "POST"
        WebRequest.ContentType = "application/x-www-form-urlencoded"
        WebRequest.GetRequestStream().Write(postdatabytes)
'WebRequest.GetRequestStream().Write(postdatabytes, 0, postdatabytes.Length)
        Dim ret As New System.IO.StreamReader(WebRequest.GetResponse().GetResponseStream())
        console.writeline(ret.ReadToEnd())
    End Sub  
  
End Module  

vbnet . का उपयोग करके वीडियो भेजें

Imports System 
Imports System.Net
Imports System.Text
Imports System.IO
Imports System.Web

Module base64  
    Sub Main()  
        Dim WebRequest As HttpWebRequest
        Dim instance_id as string ="instance1150"
        Dim token as string  ="1g55hyy7ixrsi2"
        Dim mobile_number as string  ="14155552671"
        dim ultramsgApiUrl as string  ="https://api.ultramsg.com/"+instance_id+"/messages/video"
        WebRequest = HttpWebRequest.Create(ultramsgApiUrl)
        Dim postdata As String = "token=" + token + "&to="+ mobile_number + "&video=https://file-example.s3-accelerate.amazonaws.com/video/test.mp4"
        Dim enc As UTF8Encoding = New System.Text.UTF8Encoding()
        Dim postdatabytes As Byte()  = enc.GetBytes(postdata)
        WebRequest.Method = "POST"
        WebRequest.ContentType = "application/x-www-form-urlencoded"
        WebRequest.GetRequestStream().Write(postdatabytes)
'WebRequest.GetRequestStream().Write(postdatabytes, 0, postdatabytes.Length)
        Dim ret As New System.IO.StreamReader(WebRequest.GetResponse().GetResponseStream())
        console.writeline(ret.ReadToEnd())
    End Sub  
  
End Module  

vbnet का उपयोग करके लिंक भेजें

Imports System 
Imports System.Net
Imports System.Text
Imports System.IO
Imports System.Web

Module base64  
    Sub Main()  
        Dim WebRequest As HttpWebRequest
        Dim instance_id as string ="instance1150"
        Dim token as string  ="1g55hyy7ixrsi2"
        Dim mobile_number as string  ="14155552671"
        dim ultramsgApiUrl as string  ="https://api.ultramsg.com/"+instance_id+"/messages/link"
        WebRequest = HttpWebRequest.Create(ultramsgApiUrl)
        Dim postdata As String = "token=" + token + "&to="+ mobile_number + "&link=https://en.wikipedia.org/wiki/COVID-19"
        Dim enc As UTF8Encoding = New System.Text.UTF8Encoding()
        Dim postdatabytes As Byte()  = enc.GetBytes(postdata)
        WebRequest.Method = "POST"
        WebRequest.ContentType = "application/x-www-form-urlencoded"
        WebRequest.GetRequestStream().Write(postdatabytes)
'WebRequest.GetRequestStream().Write(postdatabytes, 0, postdatabytes.Length)
        Dim ret As New System.IO.StreamReader(WebRequest.GetResponse().GetResponseStream())
        console.writeline(ret.ReadToEnd())
    End Sub  
  
End Module  

vbnet का उपयोग करके संपर्क भेजें

Imports System 
Imports System.Net
Imports System.Text
Imports System.IO
Imports System.Web

Module base64  
    Sub Main()  
        Dim WebRequest As HttpWebRequest
        Dim instance_id as string ="instance1150"
        Dim token as string  ="1g55hyy7ixrsi2"
        Dim mobile_number as string  ="14155552671"
        dim ultramsgApiUrl as string  ="https://api.ultramsg.com/"+instance_id+"/messages/contact"
        WebRequest = HttpWebRequest.Create(ultramsgApiUrl)
        Dim postdata As String = "token=" + token + "&to="+ mobile_number + "&[email protected]"
        Dim enc As UTF8Encoding = New System.Text.UTF8Encoding()
        Dim postdatabytes As Byte()  = enc.GetBytes(postdata)
        WebRequest.Method = "POST"
        WebRequest.ContentType = "application/x-www-form-urlencoded"
        WebRequest.GetRequestStream().Write(postdatabytes)
'WebRequest.GetRequestStream().Write(postdatabytes, 0, postdatabytes.Length)
        Dim ret As New System.IO.StreamReader(WebRequest.GetResponse().GetResponseStream())
        console.writeline(ret.ReadToEnd())
    End Sub  
  
End Module  

vbnet का उपयोग करके स्थान भेजें

Imports System 
Imports System.Net
Imports System.Text
Imports System.IO
Imports System.Web

Module base64  
    Sub Main()  
        Dim WebRequest As HttpWebRequest
        Dim instance_id as string ="instance1150"
        Dim token as string  ="1g55hyy7ixrsi2"
        Dim mobile_number as string  ="14155552671"
        dim ultramsgApiUrl as string  ="https://api.ultramsg.com/"+instance_id+"/messages/location"
        WebRequest = HttpWebRequest.Create(ultramsgApiUrl)
        Dim postdata As String = "token=" + token + "&to="+ mobile_number + "&address=ABC company \n Sixth floor , office 38&lat=25.197197&lng=55.2721877"
        Dim enc As UTF8Encoding = New System.Text.UTF8Encoding()
        Dim postdatabytes As Byte()  = enc.GetBytes(postdata)
        WebRequest.Method = "POST"
        WebRequest.ContentType = "application/x-www-form-urlencoded"
        WebRequest.GetRequestStream().Write(postdatabytes)
'WebRequest.GetRequestStream().Write(postdatabytes, 0, postdatabytes.Length)
        Dim ret As New System.IO.StreamReader(WebRequest.GetResponse().GetResponseStream())
        console.writeline(ret.ReadToEnd())
    End Sub  
  
End Module  

vbnet का उपयोग करके Vcard भेजें

Imports System 
Imports System.Net
Imports System.Text
Imports System.IO
Imports System.Web

Module base64  
    Sub Main()  
        Dim WebRequest As HttpWebRequest
        Dim instance_id as string ="instance1150"
        Dim token as string  ="1g55hyy7ixrsi2"
        Dim mobile_number as string  ="14155552671"
        dim ultramsgApiUrl as string  ="https://api.ultramsg.com/"+instance_id+"/messages/vcard"
        WebRequest = HttpWebRequest.Create(ultramsgApiUrl)
        Dim postdata As String = "token=" + token + "&to="+ mobile_number + "&vcard= BEGIN:VCARD\nVERSION:3.0\nN:lastname;firstname\nFN:firstname lastname\nTEL;TYPE=CELL;waid=14000000001:14000000002\nNICKNAME:nickname\nBDAY:01.01.1987\nX-GENDER:M\nNOTE:note\nADR;TYPE=home:;;;;;;\nADR;TYPE=work_:;;;;;;\nEND:VCARD"
        Dim enc As UTF8Encoding = New System.Text.UTF8Encoding()
        Dim postdatabytes As Byte()  = enc.GetBytes(postdata)
        WebRequest.Method = "POST"
        WebRequest.ContentType = "application/x-www-form-urlencoded"
        WebRequest.GetRequestStream().Write(postdatabytes)
'WebRequest.GetRequestStream().Write(postdatabytes, 0, postdatabytes.Length)
        Dim ret As New System.IO.StreamReader(WebRequest.GetResponse().GetResponseStream())
        console.writeline(ret.ReadToEnd())
    End Sub  
  
End Module  

अंत में, आप पूर्ण व्हाट्सएप एपीआई दस्तावेज़ीकरण और अक्सर पूछे जाने वाले प्रश्न देख सकते हैं।