0

I want to send sms from my java web application using SMSLib. I followed installation process from http://smslib.org/doc/installation/. but its not working.if anybody help me by any code or information of java API, i really appreciate.

public void doIt() throws Exception
{
    OutboundNotification outboundNotification = new OutboundNotification();
    System.out.println("Example: Send message from a serial gsm modem.");
    System.out.println(Library.getLibraryDescription());
    System.out.println("Version: " + Library.getLibraryVersion());
    SerialModemGateway gateway = new SerialModemGateway("modem.com1", "COM4", 9600, "Nokia", "C2-03");
    gateway.setInbound(true);
    gateway.setOutbound(true);
    gateway.setSimPin("1234");

    // Explicit SMSC address set is required for some modems.
    // Below is for VODAFONE GREECE - be sure to set your own!
    gateway.setSmscNumber("+8801700000600");
    Service.getInstance().setOutboundMessageNotification(outboundNotification);
    Service.getInstance().addGateway(gateway);
    Service.getInstance().startService();
    System.out.println();
    System.out.println("Modem Information:");
    System.out.println("  Manufacturer: " + gateway.getManufacturer());
    System.out.println("  Model: " + gateway.getModel());
    System.out.println("  Serial No: " + gateway.getSerialNo());
    System.out.println("  SIM IMSI: " + gateway.getImsi());
    System.out.println("  Signal Level: " + gateway.getSignalLevel() + " dBm");
    System.out.println("  Battery Level: " + gateway.getBatteryLevel() + "%");
    System.out.println();
    // Send a message synchronously.
    OutboundMessage msg = new OutboundMessage("+8801719057995", "call me, sanchoy");
    Service.getInstance().sendMessage(msg);
    System.out.println(msg);

    System.out.println("Now Sleeping - Hit <enter> to terminate.");
    System.in.read();
    Service.getInstance().stopService();
}
user1504940
  • 175
  • 4
  • 14
  • 2
    1876 *"Mr. Watson - come here - I want to see you."* 2012 *"call me, sanchoy"* The more things change, the more they stay the same. ;) – Andrew Thompson Jul 21 '12 at 18:06

1 Answers1

0

You could purchase a cheap 150 dollar Android phone, sign up and install the Sent.ly app from the Google Play Store and then use the API provided by Sent.ly http://sent.ly

The API is HTTP based so calling it from your web app would be really simple:

import java.net.*;
import java.io.*;

public class URLConnectionReader {
    public static void main(String[] args) throws Exception {
        String sentlyUsername = "yourusername";
        String sentlyPassword = "yourpassword";
        String destinationNumber = "+14085616821";
        String message = "This is what I want to send";
        URL sentlyService = new URL("http://sent.ly/command/sendsms" +
           "?username=" + sentlyUsername +
           "&password=" + sentlyPassword +
           "&to=" + destinationNumber +
           "&text=" + message);
        URLConnection yc = sentlyService .openConnection();
        BufferedReader in = new BufferedReader(
                                new InputStreamReader(
                                yc.getInputStream()));
        String inputLine;

        while ((inputLine = in.readLine()) != null) 
            System.out.println(inputLine);
        in.close();
    }
}

More documentation can be found here: https://docs.google.com/document/d/1MuFXPTWq7zNIChwZdzIrqiQ2-Mb3_rPrWqNlOZXJNws/edit?pli=1