HTTP SMS API - URL template

This guide gives you instructions on how to create an URL template to be used in the redirecturl, the continueurl and the reporturl parameters of the HTTP API sendmessage method.

Introduction

If the the redirecturl or the continueurl parameters are included in your sendmessage HTTP request, the SMS server will return a response containing the URL. If the URL specified contains certain keywords. The keywords will be replaced to the appropriate values corresponding to the submitted message. In other words an URL template is an URL that will be processed by the SMS gateway before it is used in the HTTP response. Processing means, that certain keywords will be replaced in the URL.

For example if you specify the following URL in the continueurl parameter:

http://www.myserver.com/index.asp?msgid=$messageid&statusmsg=$statusmessage

It will be modified into this when it is returned in the HTTP response:

http://www.myserver.com/index.asp?msgid=AC32DEF&statusmsg=Message+accepted+for+delivery

Note that the keywords $messageid and $statusmessage have been replaced. The message id of the submitted messages is substituted for the $messageid keyword in the URL and the status message of the submission is is substituted for the $statusmessage keywrod. Ozeki NG SMS Gateway replaces the keywords specified in the table bellow.

How to use?

To pass an URL template in the redirecturl, the continueurl or in the reporturl parameter, the URL template must be urlencoded. This is necessary, because otherwise the HTTP syntax of the sendmessage method would break. To urlencode your URL template you can use the online url encoding tool (available at Ozeki online url encoding tool) or you can do the encoding manually.

The URL template we used in the example above looks like this before the encoding:

http://www.myserver.com/index.asp?msgid=$messageid&statusmsg=$statusmessage

After urlencogind it will look like this:

http%3A%2F%2Fwww.myserver.com%2Findex.asp%3Fmsgid%3D%24messageid%26statusmsg%3D%24statusmessage

If you want to include this URL template in your submit request, your request would look like this:

http://127.0.0.1:9501/api?action=sendmessage&
username=admin&password=abc123&
recipient=06203105366&messagetype=SMS:TEXT&
messagedata=Hello+World&redirecturl=
http%3A%2F%2Fwww.myserver.com%2Findex.asp%3Fmsgid%3D%24messageid%26statusmsg%3D%24statusmessage

Keywords

URL templates can contain the following keywords

KeywordReplaced to Can be used in the following parameter of the HTTP API sendmessage method
statuscode The result code of the message submission redirecturl
continueurl
reporturl
statusmessage The status message of the message submission. (The statuscode explained.) redirecturl
continueurl
reporturl
messageid The id of the submitted message redirecturl
continueurl
reporturl
recipient The recipient phone number of the submitted message redirecturl
continueurl
reporturl
originator The sender name or sender phone number of the submitted message redirecturl
continueurl
reporturl
messagetype The messagetype of the submitted message redirecturl
continueurl
reporturl
messagedata The messagedata of the submitted message redirecturl
continueurl
reporturl
submitdate The date and time value of the message submission event. The date format is YYYY-MM-DD hh:mm:ss. reporturl
deliveredtonetworkdateThe date and time value of the message delivered to network event. The date format is YYYY-MM-DD hh:mm:ss. reporturl
deliveredtohandsetdateThe date and time value of the message delivered to handset event. The date format is YYYY-MM-DD hh:mm:ss. reporturl
statusThe current status of the submitted message. Possible values:

deliveredtonetwork
deliveredtohandset
deliveryfailed

If the delivery fails, the statuscode and statusmessage parameters contain the errorcode and the errormessage returned by the service provider

reporturl

If more then one messages are submitted with a single HTTP request, the URL template will contain the values corresponding to the last message in the list.

More information