Hey all,

This article here is a brief tutorial about the built-in HTTP SMS API of the Ozeki NG SMS Gateway. This API provides many possibilities for developers, so I hope it will be useful for you and the tutorial will help you understand how it operates. The HTTP SMS API can be used to send and receive SMS messages with the help of the Ozeki NG.

Now, I will focus on sending SMS messages with the help of the API.

Sending messages

https sms

For sending messages you need to use the ‘sendmessage’ method. To send SMS messages with this method you simply need to call an URL. When calling the URL, you will need to specify some parameters. I will demonstrate this through an example URL request:

‘http://127.0.0.1:9501/api?action=sendmessage&username=admin&password=abc123& recipient=06203105366&messagetype=SMS:TEXT&messagedata=Hello+World’

Now, in order to understand the structure of this URL request, let’s see what parameters are included in it.

First of all, we have an IP address and a port number. The IP address should be substituted by the address of the computer you are running the Ozeki NG SMS Gateway on. The port number is set by default; you don’t have to change that.

If we go on, we’ll see the ‘action’ parameter. That is the parameter that specifies the HTTP API command. Its value can only be ’sendmessage’.

’Username’ is used to authenticate the user (along with password). In the example URL request you can see that the value is ’admin’ for ‘username’.

The next parameter is ‘password’. As mentioned before, this is also used to authenticate the user. In the example the password is ‘abc123’.

The next parameter in the string is ‘recipient’. The message you are sending will be sent to the telephone number you enter here. You can add more than one recipient number in the URL request by separating the numbers with a colon. In the example the recipient is 06203105366.

Next step

Now let’s go on with the ‘messagetype’ parameter. Here you can specify the type of the message. In the case of our example it is a simple text, but there are other possible values you can enter here.

Finally, we have ‘messagedata’ in the example string. This parameter specifies the content of the SMS message. As you can see, the message data in the example is ‘Hello World’.

There are more optional parameters that can be added to the URL request. These are not present in this example but I’d like to mention two of them here.

One of these parameters is ‘originator’. It specifies the sender address. This value can be varied; it can be a phone number, or a string of letters and numbers, too. The recipient will see this data on the telephone after a message is received.

Another parameter is ‘sendondate’. With this you can configure the date and time when you want the message to be sent out. The format for this value is the following: YYYY-MM-DD hh:mm:ss.

HTTP response

Fine, we are done with the URL request; now let’s see an example for an HTTP response.

HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: 246

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE smsapi PUBLIC "-//OZEKI//DTD XML 1.0//EN" "http://www.ozekisms.com/DTD/smsapi.xml">
<response>
   <action>sendmessage</action>
   <data>
      <acceptreport>
         <statuscode>0</statuscode>
         <statusmessage>Message accepted for delivery</statusmessage>
         <messageid>ERFAV23D</messageid>
         <recipient>06203105366</recipient>
      </acceptreport>
   </data>
</response>

Now let’s see what the role is of the different methods in this example

The first one is ‘acceptreport’. This parameter contains the response for the submit request.

The next parameter here is ‘acceptreport.statuscode’. The value here indicates whether the message sending was successful or not. If the value is 0, that means that the message was accepted for delivery. Any values, that are greater than 0 means that an error occurred and the message was not accepted. In the example the value is 0, so everything is fine?.

The ‘acceptreport.statusmessage’ parameter is the textual representation of the status code. As the code was 0 in the example, the message here is ‘Message accepted for delivery.’ as it has to be.

The value of the ‘acceptreport.messageid’ parameter contains a message reference. This helps tracking the message in the SMS gateway. The reference of the message in the sample response is ‘ERFAV23D’.

Finally, ‘acceptreport.recipient’ contains the address of the recipient. This is ‘06203105366’ in the example.

So, that’s all for now. I hope this brief tutorial could help you understand the technology of SMS sending with our HTTP SMS API. If you feel like digging deeper in this topic, feel free to visit our webpage!

LEAVE A REPLY

Please enter your comment!
Please enter your name here