SMS Gateway

smsservice allows you to send SMSes in your applications.

How to use

Data is sent to https://helix.stormhub.org/smsservice/sendsms.php using POST.

The following fields are required:

message The message to send.
extension Up to 10 phone numbers separated by comma, e.g +46701234567,+46709876543
key_name The name of the api key to use.
key_value 344 bit api key.

The following fields are optional:

flash Send the message as a flash message.
postpone Defer sending until the date and time specified. Format: HH:mm [MMDDYY] For example: If you want to send an sms at new year's eve 2015, you would put 00:00 010115.

Notes

All sms requests are logged.

The following characters are escaped and will be replaced with space: #&;`|*?~<>^()[]{}$\, \x0A and \xFF.

Messages longer than 500 characters will be stripped.

Example

C#

Here is an example of a program in C# that sends an SMS and displays the response in a dialog box.

private void SendSms()
{
    try
    {
       /* We have to add this line to avoid 
        * error 417 - expectation failed.
        */
       System.Net.ServicePointManager.
           Expect100Continue = false;
       string baseUrl = "https://helix.stormhub.org/
           smsservice/sendsms.php";
       using (var wb = new WebClient())
       {
           var data = new NameValueCollection();
           data["message"] = "Hello World!";
           data["extension"] = "+467001234567";
           data["key_name"] = "api23";
           data["key_value"] = "4Jh3d0vbMal4cLaP4cz00lsdBpp";
           var response = wb.UploadValues(baseUrl, 
              "POST", data);
           // Display response in a dialog box
           MessageBox.Show(System.Text.Encoding.
               Default.GetString(response));
       }
     }
     catch (Exception ex)
     {
        MessageBox.Show(ex.Message);
     }
}
	

Java

Download the latest version of smsservice-lib. In Eclipse, you can include the jar file into your project by right-clicking on your project in Package Explorer and click Properties. In the list to the left, choose Java Build Path and select the tab called Libraries. Copy the jar file into your project folder and click Add Jars... to add the jar file.

Note! Oracles proprietary JDK, does not by default support 256-bit keys used by Stormhub because of US law. To overcome this problem, you'll need to download Java Cryptography Extension Unlimited Strength Jurisdiction Policy Files. Extract the contents of this archive to JAVA_HOME/jre/lib/security. You don't need to do anything if you use OpenJDK.

You can now use method chaining to send an SMS with one row of code.

import org.stormhub.helix.smsservice.SMS;

SMS.create(API_KEY_NAME, API_KEY_VALUE).
     setMessage("Hello world!").
     setRecipient("+46731234567").
     send();	
	

Changelog

2014-05-03 Long sms messages are chained. Maximum length is now 500 characters.

2014-05-03 UTF-8 characters are supported.

2014-05-04 Batch send messages. Up to 10 extensions supported.

2014-05-04 Added an option to send as a flash message.

2014-05-15 Postpone sending until the date and time specified.

2014-08-13 It is now possible to send SMS messages to an MS outside of Sweden.

2014-08-19 Released the first version of smsservice-lib.