VB.NET Code Sample

HTTP API Code Sample – VB.NET

The code sample below shows you how to send SMS messages quickly using a simple VB.NET script based on the HTTP API. The script sends a single 1-way SMS message that will appear to come from "XYZCorp".

Send a 1-Way SMS Using VB.NET

' Import the required libraries
Imports System.Net
Imports System.IO

' Create a new web client to send the request
Dim client As WebClient = New WebClient()

' Add the various parameters that need to go out
' with the HTTP request
client.QueryString.Add("username", "my_username")
client.QueryString.Add("password", "SecrEt12345")
client.QueryString.Add("message", "Hello World")
client.QueryString.Add("type", "1-way")
client.QueryString.Add("senderid", "XYZCorp")
client.QueryString.Add("to", "61400000000")

' Set the URL to send the request to, please note
' you can use either HTTP or HTTPS
Dim url As String = "http://api.directsms.com.au/s3/http

' Send the request and read the response
Dim stream As Stream = client.OpenRead(url)
Dim reader As StreamReader = New StreamReader(stream)
Dim response As String = reader.ReadToEnd()

' Close the data stream and HTTP connection

' The response from the gateway is going to look like
' this:
' id: a4c5ad77ad6faf5aa55f66a
' In the event of an error, it will look like this:
' err: invalid login credentials

The full HTTP/S API documentation details all available features of directSMS' Bulk SMS Gateway. For additional help or if you have any questions, please contact our helpful support team.