Byron Kiourtzoglou

About Byron Kiourtzoglou

Byron is a master software engineer working in the IT and Telecom domains. He is always fascinated by SOA, middleware services and mobile development. Byron is co-founder and Executive Editor at Java Code Geeks.

Java API for Kannel SMS/WAP gateway v 1.0.2 released

Hello all, we released version 1.0.2 of Java API for Kannel SMS/WAP gateway.

The latest version introduces prioritized WAP Push functionality and bulk WAP Push messaging.

You can download the new version here

An example use of the API is shown below :
 
 
 
 

public static void main(String[] args) {

 SMSManager smsManager = SMSManager.getInstance();

 // We can change the prefetch size of the background worker thread
 smsManager.setMessagesPrefetchSize(30);

 // We can change the send message rate
 smsManager.setMessagesSendRate(65);

 try {

  // Send SMS to a single destination
  smsManager.sendSMS("localhost", "13013", "foo", "bar", "sender_mobile_number", "receiver_mobile_number", "the_message");

  // Send SMS to a single destination with a specific priority and send rate
  smsManager.sendSMS("localhost", "13013", "foo", "bar", "sender_mobile_number", "receiver_mobile_number", "the_message", SMSManager.MESSAGE_PRIORITY_3);

  // Send SMS to multiple recipients
  List<String> recipientsGroupA = new ArrayList<String>();
  recipientsGroupA.add("receiver_mobile_number_1");
  recipientsGroupA.add("receiver_mobile_number_2");
  recipientsGroupA.add("receiver_mobile_number_3");
  recipientsGroupA.add("receiver_mobile_number_4");
  recipientsGroupA.add("receiver_mobile_number_5");
  smsManager.sendSMS("localhost", "13013", "foo", "bar", "sender_mobile_number", recipientsGroupA, "the_message");

  // Send SMS to multiple recipients with a specific priority and send rate
  List<String> recipientsGroupB = new ArrayList<String>();
  recipientsGroupB.add("receiver_mobile_number_1");
  recipientsGroupB.add("receiver_mobile_number_2");
  recipientsGroupB.add("receiver_mobile_number_3");
  recipientsGroupB.add("receiver_mobile_number_4");
  recipientsGroupB.add("receiver_mobile_number_5");
  smsManager.sendBulkSMS("localhost", "13013", "foo", "bar", "sender_mobile_number", recipientsGroupB, "the_message", SMSManager.MESSAGE_PRIORITY_7);

  // Send a WAP Push request to a single mobile recipient
  smsManager.sendWAPPush("localhost", "8181", "receiver_mobile_number", SMSManager.WAP_PUSH_RECEIVER_TYPE_MOBILE, "the_message", "http://localhost", 3);

  // Send a WAP Push request to a single destination with a specific priority and send rate
  smsManager.sendWAPPush("localhost", "8181", "receiver_mobile_number", SMSManager.WAP_PUSH_RECEIVER_TYPE_MOBILE, "the_message", "http://localhost", 3, SMSManager.MESSAGE_PRIORITY_8);

  // Send WAP Push request to multiple recipients with a specific priority and send rate
  List<String> recipientsGroupC = new ArrayList<String>();
  recipientsGroupC.add("receiver_mobile_number_1");
  recipientsGroupC.add("receiver_mobile_number_2");
  recipientsGroupC.add("receiver_mobile_number_3");
  recipientsGroupC.add("receiver_mobile_number_4");
  recipientsGroupC.add("receiver_mobile_number_5");
  smsManager.sendBulkWAPPush("localhost", "8181", recipientsGroupC, SMSManager.WAP_PUSH_RECEIVER_TYPE_MOBILE, "the_message", "http://localhost", 3, SMSManager.MESSAGE_PRIORITY_8);

 } catch (Exception ex) {
  ex.printStackTrace();
 }

 // Stops the background worker.
 // smsManager.stopSMSManagerWorker();

}

Best Regards

Justin

Related articles :
Related Whitepaper:

Java Essential Training

Author David Gassner explores Java SE (Standard Edition), the language used to build mobile apps for Android devices, enterprise server applications, and more!

The course demonstrates how to install both Java and the Eclipse IDE and dives into the particulars of programming. The course also explains the fundamentals of Java, from creating simple variables, assigning values, and declaring methods to working with strings, arrays, and subclasses; reading and writing to text files; and implementing object oriented programming concepts. Exercise files are included with the course.

Get it Now!  

12 Responses to "Java API for Kannel SMS/WAP gateway v 1.0.2 released"

  1. Xander says:

    Hi Justin,

    Can you please explain the steps required to configure the API. What all needs to be deployed on local machine on the port 13013 and all. I try to ran this example but as port 13013 on my local machine was not being listened by any program the socket connection failed.

    Thanx,
    X.

  2. Mitesh Patel says:

    Can you tell me how to use a send sms function with DLR..

  3. Albert says:

    Please help me!
    I use:

    // Send a WAP Push request to a single mobile recipient
    smsManager.sendWAPPush(“localhost”, “8181″, “receiver_mobile_number”, SMSManager.WAP_PUSH_RECEIVER_TYPE_MOBILE, “the_message”, “http://localhost”, 3);

    But
    My errors:
    java.io.FileNotFoundException: http://localhost:8080/wappush
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
    at com.javacodegeeks.kannel.api.SMSManager.sendWAPPush(SMSManager.java:793)
    at com.javacodegeeks.kannel.api.SMSManager.sendWAPPush(SMSManager.java:708)

    Thanks!

    • Albert says:

      Sorry, I’m using:
      // Send a WAP Push request to a single mobile recipient
      smsManager.sendWAPPush(“localhost”, “8080″, “receiver_mobile_number”, SMSManager.WAP_PUSH_RECEIVER_TYPE_MOBILE, “the_message”, “http://localhost”, 3);

  4. raju says:

    HI ,

    I am kannel sms API in my java application
    smsManager.sendSMS(“localhost”, “9080″, “foo”, “bar”, “send_number”, “rec_number”, “Hi Test”);

    I am getting below exception
    java.net.ConnectException: Connection refused: connect.

    please help to configure kannel sms api.

    Thanks.

  5. kishore says:

    1)Send SMS with priority is not been sent to the SMPPsim that has been configured. SMS send without priority are submitted to the SMSC with no issues. Can anyone revert back on this, as on what need to be done to submit sms with priority.

    2)How to get the delivery status if the submitted message from this program to the kannel router?

    thanks.

  6. hemanth says:

    hi how can i get replay message (MO) from this api

Leave a Reply


6 × three =



Java Code Geeks and all content copyright © 2010-2014, Exelixis Media Ltd | Terms of Use | Privacy Policy
All trademarks and registered trademarks appearing on Java Code Geeks are the property of their respective owners.
Java is a trademark or registered trademark of Oracle Corporation in the United States and other countries.
Java Code Geeks is not connected to Oracle Corporation and is not sponsored by Oracle Corporation.
Do you want to know how to develop your skillset and become a ...
Java Rockstar?

Subscribe to our newsletter to start Rocking right now!

To get you started we give you two of our best selling eBooks for FREE!

Get ready to Rock!
You can download the complementary eBooks using the links below:
Close