Ozeki NG SMS Gateway logo OZEKI NG SMS Gateway
"The World's most reliable SMS gateway software!"
info@ozekisms.com
Tel.: 00 36 52 532 731
SMS Gateway to send SMS via GSM modem or IP SMS connection Overview SMS Gateway to send SMS via GSM modem or IP SMS connection SMS Gateway to send SMS via GSM modem or IP SMS connection Quick start SMS Gateway to send SMS via GSM modem or IP SMS connection SMS Gateway to send SMS via GSM modem or IP SMS connection Download SMS Gateway to send SMS via GSM modem or IP SMS connection SMS Gateway to send SMS via GSM modem or IP SMS connection Manual SMS Gateway to send SMS via GSM modem or IP SMS connection SMS Gateway to send SMS via GSM modem or IP SMS connection How to buy SMS Gateway to send SMS via GSM modem or IP SMS connection SMS Gateway to send SMS via GSM modem or IP SMS connection FAQ SMS Gateway to send SMS via GSM modem or IP SMS connection SMS Gateway to send SMS via GSM modem or IP SMS connection Contact Us SMS Gateway to send SMS via GSM modem or IP SMS connection
OZEKI NG SMS Gateway - Product Guide

VB.NET database sms example guide Contents | SearchPython SMS API

Home > Product Manual > Developers Guide > VB.NET SMS API > VB.NET HTTP sms example guide

SMS Gateway SMS Gateway Home

  Product Manual
  Introduction
  SMS technology
  Installation Guide
  User Guide
  Developers Guide
  Tutorials
  ASP SMS API
  PHP SMS API
  HTTP SMS API
  SQL SMS API
  C Sharp SMS API
  AJAX SMS API
  Delphi SMS API
  Cpp SMS API
  Java SMS API
  VB.NET SMS API
  VB.NET database sms example guide
  VB.NET HTTP sms example guide
  Python SMS API
  Perl SMS API
  TCL/TK SMS API
  Coldfusion SMS API
  VB 6 SMS API
  Examples and Solutions
  Appendix
  FAQ
  Feature list
  Commercial Information
  Search
  Cookie policy
 


Automated phone calls?
Ozeki Phone System XE VoIP PBX software is an advanced PBX built for automated voice calls and 2 way SMS messaging. It has outstanding APIs for software developers. It can be used for:

Phone calls from SQL
Phone calls from HTTP
Voice and SMS applications

Callcenter developers
If you are working on telephone solutions, please check out the Ozeki VoIP SIP SDK.
It can be used to create VoIP client and server software.

Contact Us!
If you wish to get further information, do not hesitate to contact us!

E-mail: info@ozekisms.com

If you have a technical question, please submit a support request on-line.

How to send SMS from VB.Net using HTTP requests

Download: send-sms-vb.net-http-sms-example.zip (106 Kb)

This guide will provide you information on how to send and receive SMS messages using HTTP requests from a VB.Net application. The information provided here can be used to send SMS messages through your own SMS Gateway (e.g.: Ozeki NG SMS Gateway), or you can modify this code to connect to any HTTP SMS Service Provider over the Internet.

Introduction

Visual Basic .Net is an excellent programming language for creating dynamic web pages and standard applications. It offers great flexibility in all fields. VB.Net developers are often required to add mobile messaging capability to their applications. Sending SMS text messages to mobile users, tracking the status of these messages and the ability to receive SMS text messages can greatly improve the value of a VB.Net program. If you are faced with such a requirement, the simplest and most convenient way to add SMS messaging functionality to your system is to use an HTTP SMS gateway, such as Ozeki NG SMS Gateway and to post SMS messages to this gateway using HTTP requests (Figure 1).




Figure 1 - How to send SMS from VB.NET using HTTP requests

If you use HTTP in your VB.Net application, you can also receive SMS messages. You can do this in two ways. You can configure an HTTP Client user in Ozeki NG SMS Gateway to forward incoming SMS messages to your VB.Net program. This solution requires you to be able to process incoming HTTP requests. The second option is to periodically download incoming messages and the delivery reports of these messages from Ozeki NG SMS Gateway.

Prerequisites

To be able to send SMS messages from your VB.Net application, you need to download and install Ozeki NG SMS Gateway. After Ozeki NG SMS Gateway has been installed, you can use Microsoft Visual Studio or any other IDE, that let's you develop VB.Net code, to develop your solution. You can use the source code on this webpage to create the functionality. So here is your checklist:

Setting up the system and writing the code

Ozeki NG SMS Gateway can be setup very easily. The SMS quick start guide gives you information on how to install and connect this gateway to the mobile network. After you have installed Ozeki NG SMS Gateway, you need to create a HTTP Server user in it. You can do this by clicking on the "Add new user or application..." link in it's management window. When you create the HTTP Server user, you provide a username and password. You need to use this username and password in the VB.Net source code.

Step 1 - Setup the connection parameters in the VB.Net example code

If you open the VB.Net demo project, you will find the following section:

Dim request As HttpWebRequest
Dim response As HttpWebResponse = Nothing
Dim url As String
Dim username As String = "admin"
Dim password As String = "abc123"
Dim host As String = "http://127.0.0.1:9501"
Dim originator As String = "06201234567"

In this section, you need to provide the username and password you have specified, when you have created the HTTP Server user in Ozeki NG SMS Gateway. If your VB.Net application runs on a different computer, than the one Ozeki NG SMS Gateway is installed on, you need to change the host parameter as well. You can also specify a sender ID value to be used as the originator phone number when you are sending SMS messages.

Step 2 - Compose of the URL

The next section of the VB.Net HTTP SMS example code is the composition of the HTTP URL, that will be used to post your SMS message to the SMS Gateway. This URL contains parameters that are specified in the Ozeki HTTP SMS API specification. Note that when you compose this URL you have to URL encode the values. This is necessary to make sure that the special characters will not break the HTTP specification.

url = host + "/api?action=sendmessage&" _
& "username=" & HttpUtility.UrlEncode(username) _
& "&password=" + HttpUtility.UrlEncode(password) _
& "&recipient=" + HttpUtility.UrlEncode(tbReceiver.Text) _
& "&messagetype=SMS:TEXT" _
& "&messagedata=" + HttpUtility.UrlEncode(tbMessage.Text) _
& "&originator=" + HttpUtility.UrlEncode(originator) _
& "&serviceprovider=" _
& "&responseformat=html"

Step 3 - Submit the URL

To send your SMS message you need to initiate a HTTP request using the Webrequest VB.Net method. After the request has been sent, you can read the response returned by the SMS gateway using the request.GetResponse() method and you can show the response message in a popup window.

request = DirectCast(WebRequest.Create(url), HttpWebRequest)

Receiving the answer.

response = DirectCast(request.GetResponse(), HttpWebResponse)

Displaying the answer in a pop-up window

MessageBox.Show("Response: " & response.StatusDescription)

As you can see it is very simple to send an SMS message through an HTTP request. All you have to do is understand the HTTP SMS API parameters and you need to send and receive a request using the built in VB.Net methods. Finally take a look at the full source code we used in this article:

Full source code

Please feel free to use and modify the source code sample.

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

Public Class fMain

 Private Sub bSend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bSend.Click
        Dim request As HttpWebRequest
        Dim response As HttpWebResponse = Nothing
        Dim url As String
        Dim username As String
        Dim password As String
        Dim host As String
        Dim originator As String

        Try

            host = "http://127.0.0.1:9501"
            originator = "06201234567"
            username = "admin"
            password = "abc123"

            url = host + "/api?action=sendmessage&" _
                     & "username=" & HttpUtility.UrlEncode(username) _
                     & "&password=" + HttpUtility.UrlEncode(password) _
                     & "&recipient=" + HttpUtility.UrlEncode(tbReceiver.Text) _
                     & "&messagetype=SMS:TEXT" _
                     & "&messagedata=" + HttpUtility.UrlEncode(tbMessage.Text) _
                     & "&originator=" + HttpUtility.UrlEncode(originator) _
                     & "&serviceprovider=GSMModem1" _
                     & "&responseformat=html"

            request = DirectCast(WebRequest.Create(url), HttpWebRequest)

            response = DirectCast(request.GetResponse(), HttpWebResponse)

            MessageBox.Show("Response: " & response.StatusDescription)

        Catch ex As Exception
        End Try
    End Sub
End Class

Dig deeper!
People who read this also read...






Next page: Python SMS API
Copyright © 2000 - 2017 Ozeki Informatics Ltd.
All rights reserved

Software PBX for Windows | VoIP SDK   |   Legal information   |   Privacy policy   |   Terms of use
Please, address your inquiries to info@ozekisms.com