Monday, 24 May 2010

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 :



4 comments:

  1. Excellent post, I have a question ..... maybe I could help
    -> How could I know if the message was sent to Kannel was successful
    -> How could I know if the message was sent from Kannel to the carrier received a satisfactory result

    Thank you very much for your help.

    ReplyDelete
  2. Hello Josue,

    Either a SMSPushRequestException or a WAPPushRequestException will be thrown to your client if Kannel returns an invalid response code (other than 0 for SMS and 1001 for WAP Push). Both Exceptions contain the code of Kannel response. As far as the delivery report, this version does not implement delivery report handling. Nevertheless we plan to add it in the near future, so stay tuned!

    BRs

    ReplyDelete
  3. Hello!
    Will it support receiving of SMS?
    Thanks!

    ReplyDelete
  4. Hello Sándor,

    Yes it will support receiving SMS in the upcoming version, so stay tuned!

    BRs

    ReplyDelete

Related Posts Plugin for WordPress, Blogger...