Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Exemple en VB d'envoi de SMS unitaire
Public Sub Main(ByVal Args() As String)
' Création du XML à poster
Dim xml As String = "<request login=""your-login"" password=""your-password"">" & _
"<push media=""sms"" type=""on_demand"" name=""Test API Sms VB.NET"">" & _
"<message type=""text"">Mon premier test sms</message>" & _
"<recipients>" & _
"<add target=""+33 600000000"" />" & _
"</recipients>" & _
"</push>" & _
' Construction et envoi de la requête HTTP
Dim request As WebRequest = WebRequest.Create("")
request.Method = "POST"
request.ContentType = "application/x-www-form-urlencoded"
Dim byteArray() As Byte = System.Text.Encoding.UTF8.GetBytes(xml)
request.ContentLength = byteArray.Length
Dim dataStream As System.IO.Stream = request.GetRequestStream()
dataStream.Write(byteArray, 0, byteArray.Length)
Dim response As WebResponse = request.GetResponse()
Dim responseStream = response.GetResponseStream()
Dim reader As System.IO.StreamReader = New System.IO.StreamReader(responseStream)
Dim responseFromServer As String = reader.ReadToEnd()
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment