Send SMS from your web application

Posted by
Today mobile phone is the most effective way to reach people/customer. Every organization is using it.If you are making an application for any organization and want to add this feature in your application, its quiet easy. There are so many gateways available online. You can use any of them, which ever suits with your requirement. One of them is SMS GATEWAY HUB. You can use its trial pack by registering yourself on http://smslogin.in/.Every SMS Gateway provides HTTP API to embed into your application.Following is HTTP API for sending sms to a group (collection of some contacts).
http://smslogin.in/API/WebSMS/Http/v1.0a/index.php?username=java2career&password=Your+Password&sender=my+senderID&group=groupid&message=Hello+Test+Message&reqid=1&format={json|text}&route_id=route+id&callback=Any+Callback+URL&unique=0&sendondate=03-12-2013T01:03:46

You can embed this by following code:
 import java.io.BufferedReader;  
 import java.io.InputStreamReader;  
 import java.io.OutputStreamWriter;  
 import java.net.URL;  
 import java.net.URLConnection;  
 import java.net.URLEncoder;  
 class sendBulkSMS  
 {  
   public static void main(String ar[])  
   {  
     try  
     {  
        String SMSURL = "http://smslogin.in/API/WebSMS/Http/v1.0a/index.php";  
        String SENDER = "1038";  
        String USERNAME = "java2career";  
        String PASSWORD = "your_password";  
        String TXT = "Hello all java2career fans";  
        String GROUP="1655";  
        String q = "username=" + URLEncoder.encode (USERNAME, "UTF-8");  
        q += "&" + "password=" + URLEncoder.encode (PASSWORD, "UTF-8");  
        q += "&" + "sender=" + SENDER;  
        q += "&" + "message=" + URLEncoder.encode (TXT, "UTF-8");  
       q += "&" + "group=" + URLEncoder.encode (GROUP, "UTF-8");  
       q += "&format={json|text}&unique=0&sendondate=03-12-2013T01:03:46";  
       URL url=new URL(SMSURL);  
        URLConnection conn = url.openConnection();  
        conn.setDoOutput (true);  
        OutputStreamWriter wr = new OutputStreamWriter (conn.getOutputStream());  
        wr.write (q);  
        wr.flush();  
      BufferedReader rd = new BufferedReader (new InputStreamReader (conn.getInputStream()));  
      String line;  
      System.out.println ("Response :");  
      while ((line = rd.readLine()) != null) { System.out.println (line); }  
      wr.close();  
      rd.close();  
     }  
     catch (Exception e) { }  
   }  
 }   
Description:
SENDER is sender id created by smslogin interface.
GROUP is group id, that you will have to create by clicking on address book->add to send sms to a group.
USERNAME and PASSWORD is which you have choosen on the time of registering yourself on smslogin.in/
TXT is the message you want to send. 
Whoaa its done!!!!

Leave a Reply