Hi, Friends with this post i will show to how to send an sms through JAVA/JSP/SERVLETS
For sending sms I am using mvayoo.
First what is mVaayoo, It is a cost effective End-to-End Enterprise Mobile Messaging Service with high service level availability, that is unmatched in the industry. mVaayoo provides both 1-Way & 2-Way SMS communication including SMS Push, short code and long code services, SMS gateway with APIs, SMS Excel plugin, SMS contest, voting & polling and Voice SMS services.
URL : http://www.mvayoo.com
You first register in this website and continue your tutorial ...
------------------------------------------------------------------------------------------------------------
Note : We can send only 20 sms with the free account... If you want more choose the premium plan or register with another account.
------------------------------------------------------------------------------------------------------------
coming to the program...;
import java.io.*;
import java.security.*;
import java.net.*;
public class SMS //Save the file with the name "SMS.java"
{
public static void main(String[] args)
{
String phnum= "9292929292"; // Example Phone Number
String message = "Hai, How are you ..."; //Example Message
try{
//http://api.mVaayoo.com/mvaayooapi/MessageCompose?user=USERNAME:PASSWORD&senderID=TEST SMS&receipientno=RECEIPIENTNO&dcs=0&msgtxt=This is Test message&state=4
URL myurl = new URL("http://api.mvaayoo.com/mvaayooapi/MessageCompose?user=USERNAME:PASSWORD&senderID=TEST%20SMS&receipientno="+phnum+"&dcs=0&msgtxt="+message+"");
BufferedReader in = new BufferedReader(new InputStreamReader(myurl.openStream()));
String inputLine;
while ((inputLine = in.readLine())!= null)
System.out.println(inputLine);
in.close();
}
catch(Exception e){
System.out.println("error"+e);
}
}
}
OUTPUT :
Hai, How are you ...
Status=0,ins37_14066345089954
Observe the output, in output "Hai, How are you ..." is our message and the second line is for status indication if your message is send successful it shows the output like "Status=0", Other wise it will not send ..
------------------------------------------------------------------------------------------------------------
NOTE : INTERNET Connection must required for sending an sms ...
------------------------------------------------------------------------------------------------------------
For sending sms I am using mvayoo.
First what is mVaayoo, It is a cost effective End-to-End Enterprise Mobile Messaging Service with high service level availability, that is unmatched in the industry. mVaayoo provides both 1-Way & 2-Way SMS communication including SMS Push, short code and long code services, SMS gateway with APIs, SMS Excel plugin, SMS contest, voting & polling and Voice SMS services.
URL : http://www.mvayoo.com
You first register in this website and continue your tutorial ...
------------------------------------------------------------------------------------------------------------
Note : We can send only 20 sms with the free account... If you want more choose the premium plan or register with another account.
------------------------------------------------------------------------------------------------------------
coming to the program...;
import java.io.*;
import java.security.*;
import java.net.*;
public class SMS //Save the file with the name "SMS.java"
{
public static void main(String[] args)
{
String phnum= "9292929292"; // Example Phone Number
String message = "Hai, How are you ..."; //Example Message
try{
//http://api.mVaayoo.com/mvaayooapi/MessageCompose?user=USERNAME:PASSWORD&senderID=TEST SMS&receipientno=RECEIPIENTNO&dcs=0&msgtxt=This is Test message&state=4
URL myurl = new URL("http://api.mvaayoo.com/mvaayooapi/MessageCompose?user=USERNAME:PASSWORD&senderID=TEST%20SMS&receipientno="+phnum+"&dcs=0&msgtxt="+message+"");
BufferedReader in = new BufferedReader(new InputStreamReader(myurl.openStream()));
String inputLine;
while ((inputLine = in.readLine())!= null)
System.out.println(inputLine);
in.close();
}
catch(Exception e){
System.out.println("error"+e);
}
}
}
OUTPUT :
Hai, How are you ...
Status=0,ins37_14066345089954
Observe the output, in output "Hai, How are you ..." is our message and the second line is for status indication if your message is send successful it shows the output like "Status=0", Other wise it will not send ..
------------------------------------------------------------------------------------------------------------
NOTE : INTERNET Connection must required for sending an sms ...
------------------------------------------------------------------------------------------------------------
4 comments
Nice post it is very useful for all. This blog is so informative for providing a valuable information about sending sms api java.
errorjava.io.IOException: Server returned HTTP response code: 505 for URL: http://api.mVaayoo.com/mvaayooapi/MessageCompose?user=kabilramarpraga@gmail.com:110611061106&senderID=TEST SMS&receipientno=8248848696&msgtxt=This is a test from mVaayoo API&state=4
errorjava.io.IOException: Server returned HTTP response code: 400 for URL: http://api.mvaayoo.com/mvaayooapi/MessageCompose?user=vamsigunturu.trylogic@gmail.com:Trylogic8&senderID=TESTSMS&receipientno=9885661384&dcs=0&msgtxt=Hai, How are you ...
how can i resolve above error
EmoticonEmoticon