We are proud to present Java API for Kannel. You can use the API to :
- Send SMS to a single recipient
- Send SMS to multiple recipients (bulk SMS)
- Send SMS with priority
- Send WAP Push message to a single recipient
- Configure send rate (SMS/Second)
Below is an example use of the API
public static void main(String[] args) {
SMSManager smsManager = SMSManager.getInstance();
// We can change the prefetch size of the background worker thread
smsManager.setSmsMessagesPrefetchSize(30);
// We can change the send SMS rate
smsManager.setSmsMessagesSendRate(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", "8080", "receiver_mobile_number", SMSManager.WAP_PUSH_RECEIVER_TYPE_MOBILE, "the_message", "http://localhost", 3);
} catch (Exception ex) {
ex.printStackTrace();
}
// Stops the background worker
// smsManager.stopSMSManagerWorker()
}
The API is hosted on Sourceforge. You can download it from here
Any comments are most welcome!
Have Fun!
Justin
Related articles :





