VB.NET HTTP SMS example
See how to add SMS functionality to your VB.NET application. For the solution you will only need an Ozeki 10 and a Microsoft Visual Studio. The communication will work through the HTTP protocol. The source code is provided. You can download and edit it.
VB.NET applications can be flexibly developed for creating dynamic web pages and standard applications. Developers are usually required to add mobile messaging to their applications, so users can send SMS messages to any recipient. Usually the most simplest and convenient way to add a SMS messaging to your system is by using a HTTP SMS gateway, such as Ozeki 10's SMS Gateway application and post messages to this gateway using HTTP requests (Figure 1).
Besides sending SMS messages, you can receive them too with VB.NET. You can do this in two ways. The easiest way is to create a HTTP Client User in Ozeki SMS Gateway, which can forward incoming messages to your VB.NET programcodes. This works if you are able to process HTTP requests. The other way is to periodically download incoming messages. You can download text messages with delivery reports from Ozeki SMS Gateway.
There are only two prerequisites you should download. Ozeki 10's SMS Gateway application and Microsoft Visual Studio for coding VB.NET. Both are the two ends of the HTTP communication. Besides Microsoft Visual Studio you can use any other IDE that let's you develop in VB.NET. If you scroll bellow you can see the VB.NET example codes for the HTTP application. Here you can find the software checklist and the example program:
Set up Ozeki 10 and run the example code
You can easily download and install Ozeki 10. Check the SMS quick start guide to easily connect it to the mobile network. You will also need to create a HTTP Server Connection in Ozeki 10. Click 'Add new user or application...' and look for the HTTP Server Connection in the list. Click the blue 'Install' button next to it (Figure 2).
You will need to provide the username and password. Do not forget these login credentials. You will need to provide them in VB.NET by replacing the example strings in the source code.
Step 1 - Set up the connection parameters in the VB.NET example code
Open the VB.NET example project and rewrite the necessary parameters (Code 1).
The 'username' and 'password' strings are the login credentials belonging to the HTTP Server Connection. If Ozeki 10 and your VB.NET application is running on different machines then it is required to rewrite the 'host' parameter to the IP address and port number of the Ozek 10 machine. The 'originator' is the phone number used as the sender.
Step 2 - Compose URL from parameters
Code 2 composes a HTTP request from the parameters provided in Code 1. This URL will be used to post your SMS message to Ozeki 10's SMS Gateway application. All parameters specified in the Ozeki HTTP SMS API documentation can be contained in the URL. The values must be URL encoded, so special characters can not break the HTTP specification.
Step 3 - Submit URL to Ozeki 10
Code 3 contains the last three lines of this VB.NET example. It sends the HTTP request and shows the response in a pop-up window. The WebRequest.Create("...") built in VB.NET method sends the URL to Ozeki 10, while GetResponse() method collects the response. It will appear in a pop-up window generated with the MessageBox.Show("...") method.
It is advised to walk through the HTTP API actions and the corresponding parameters to control Ozeki 10 through the HTTP API. This way you can create request URLs for your needs.
Full VB.NET example code
The full code you can see below (Code 4) is built up from segments described above (Code 1 - 3). You can freely use and modify the example code as you wish. An exception can be dropped if it is a problem with the HTTP communication.