Skip to content

Instantly share code, notes, and snippets.

@expressmailing
Created January 3, 2018 13:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save expressmailing/48b364acac9bdc5685a22a781bcdc987 to your computer and use it in GitHub Desktop.
Save expressmailing/48b364acac9bdc5685a22a781bcdc987 to your computer and use it in GitHub Desktop.
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>" & _
"</request>"
' Construction et envoi de la requête HTTP
Dim request As WebRequest = WebRequest.Create("http://api.express-mailing.com/transac/api.ashx")
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)
dataStream.Close()
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()
Console.WriteLine(responseFromServer)
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment