How to send an SMS from the Browser
After reading this lecture you will be able to send SMS messages to pre-setup HTTP API users using Ozeki 10 SMS Gateway. You will see how to compose the API command and how it works. Lastly you will see what message the browser returns if the request was successful and the error message.
Prerequisites
Steps to send an SMS in the browser
- Open a browser window
- Click into the URL textbox
- Type in the sms command template
- Find out the IP address of the sms gateway
- Find out the port number of the HTTP API user
- Refit the command to your likes
- Hit enter to summit the sms.
- Check the response
Open a browser
Click in the URL textbox
Type in the command template
Command template:
https://IP
:PORT
/api?action=sendmessage&username=USER
&password=PASS
recipient=NUMBER
&messagetype=SMS:TEXT&messagedata=MESSAGE
Check your IP address
1.) Press the win key and start typing cmd.
2.) Click on the command shell icon.
3.) Type ipconfig
4.) Hit enter
5.) If you use ethernet then go to the line with IPv4 Address and there you will find your IP.
If you use Wifi then go to the Wireless LAN adapter Wi-Fisection and on the IPv4 Address you will find your IP.
Replace the API commands parameters to your case
Replace the IP highlighted in red to your computers IP address
https://IP:PORT/api?action=sendmessage&username=USER&password=PASS recipient=NUMBER&messagetype=SMS:TEXT&messagedata=MESSAGE
Replace the PORT highlighted in orange to your HTTP API users port number.
1.) Click on the advanced button on the top toolbar.
2.) Then click on the details button.
3.) Finally in the HTTPS PORT input field you will find your port number.
https://IP:PORT/api?action=sendmessage&username=USER&password=PASS recipient=NUMBER&messagetype=SMS:TEXT&messagedata=MESSAGE
Replace the USER highlighted in green to your HTTP API users namehttps://IP:PORT/api?action=sendmessage&username=USER&password=PASS recipient=NUMBER&messagetype=SMS:TEXT&messagedata=MESSAGE
Replace the PASS highlighted in purple to your HTTP API user's password
https://IP:PORT/api?action=sendmessage&username=USER&password=PASS recipient=NUMBER&messagetype=SMS:TEXT&messagedata=MESSAGE
Replace the NUMBER highlighted in blue to the phone's phone number you want to send the SMS to.
https://IP:PORT/api?action=sendmessage&username=USER&password=PASS recipient=NUMBER&messagetype=SMS:TEXT&messagedata=MESSAGE
Finally Replace the MESSAGE highlighted in turquoise to a text you want to send but substitute all spaces with + signs
https://IP:PORT/api?action=sendmessage&username=USER&password=PASS recipient=NUMBER&messagetype=SMS:TEXT&messagedata=MESSAGE
Finish off
Now that you have fully filled in the parameters this is how your URL textbox should look.
Now press enter.
Outcome
This is how your browser should look like now.
The line highlighted in blue tells you what happened to the message.
The line highlighted in red tells you who have you sent it to.
Message should also arrive at the phone.
Error message
Another scenario is when you did not fill in the parameters as required.
Then this is how browser should appear.
The line in Red is what tells you what went wrong.
Now let's look into how the command works
The first key part is when we write api:
https://IP:PORT/api?action=sendmessage&username=USER&password=PASS
recipient=NUMBER&messagetype=SMS:TEXT&messagedata=MESSAGE
Description:
This is when we address the API.
After this we addressed some values where the first one was the action:
https://IP:PORT/api?action=sendmessage&username=USER&password=PASS
recipient=NUMBER&messagetype=SMS:TEXT&messagedata=MESSAGE
Description:
The action value describes the action we want to make but at the
current moment has
only one value which is sendmessage.
The next value was the username:
https://IP:PORT/api?action=sendmessage&username=USER&password=PASS
recipient=NUMBER&messagetype=SMS:TEXT&messagedata=MESSAGE
Description:
The username value tells what user to use to send the message and
needs to be URL encoded.
The max length is 16 characters.
After that came the password:
https://IP:PORT/api?action=sendmessage&username=USER&password=PASS
recipient=NUMBER&messagetype=SMS:TEXT&messagedata=MESSAGE
Description:
The password value tells what password to use when using the user and
needs to be URL encoded.
The max length is 16 characters.
The next was the recipient:
https://IP:PORT/api?action=sendmessage&username=USER&password=PASS
recipient=NUMBER&messagetype=SMS:TEXT&messagedata=MESSAGE
Description:
The recipient value describes the name of the device we are sending
to and needs to be URL encoded.
The max length is 16 characters.
The next value was the messagetype:
https://IP:PORT/api?action=sendmessage&username=USER&password=PASS
recipient=NUMBER&messagetype=SMS:TEXT&messagedata=MESSAGE
Description:
The messagetype contains the type of message we want to send and
needs to be URL encoded.
To see the possible values the mobile message type specification lists the supported message types by Ozeki 10 SMS Gateway.
The next value was the messagedata:
https://IP:PORT/api?action=sendmessage&username=USER&password=PASS
recipient=NUMBER&messagetype=SMS:TEXT&messagedata=MESSAGE
Description:
The messagedata this contains the data we need to send, must be
encoded in UTF8 and needs to be URL encoded.
The max length is 32768.
See more properties we can add to our SMS API command and get a more in-depth explanation.
To sum it up
This article explained how to send an SMS message directly from your browser. Sending SMS from your browser using the Ozeki SMS Gateway will make the flow of information easier and faster. This service can be put into use and can make your organization more efficient because it allows the information to be delivered to mobile phones.
If you want to build a flexible SMS solution, you should not stop reading here. Ozeki has more article that can help you with this project : How to send SMS with Java, or How to send SMS with Python.
Now your next thing to do is to download Ozeki SMS Gateway and configure this solution immediately! Everything is there to get it up and running in less than 10 minutes.
More information
- Send SMS from a Browser using a HTTP request
- How to send SMS from java
- How to send SMS from php
- How to send SMS from perl
- How to send SMS from Python
- Ruby send SMS with the HTTP rest API (code sample)