Examples

This document provides some simple examples to get you up and running quickly.

  1. Creating a Service
  2. Sending an SMS
  3. Setting a Proxy Server

Creating a Service

Specify a set of properties to be used in addition or instead of the default properties defined in orcus-sms.properties and pass them to the createService() method of the SmsServiceFactory.

The SmsServiceFactory implementation that will be used is determined by the net.sf.orcus.sms.SmsServiceFactory property. The default factory is an AspSmsServiceFactory and will thus return an AspSmsService implementation.

// properties specific for aspsms service
Properties props = new Properties();
props.put(AspSmsService.USERKEY_PROPERTY, "XTZ789");
props.put(AspSmsService.PASSWORD_PROPERTY, "myaspsmspw");

SmsService service = SmsServiceFactory.getFactory().createService(props);

Sending an SMS

Once you have obtained an SmsService as described above, you can use it.

try {
    service.send(sms);
    double credits = service.getCredits();
} catch (SmsServiceException e) {
    /* exception handling omitted */
}

Setting a Proxy Server

If you are behind a proxy server, you will need to have to set the standard Java networking properties before you use the service.

System.setProperty("http.proxyHost", "http://proxy.company.com");
System.setProperty("http.proxyPort", "8088");