preraksheth
asked on
Sending SMS from Java
How to send SMS using Java API? (If someone can help with free SMS in India, it would be great)
On a wider note, how to interface with Mobile network using desktop Java? Is it possible?
Could we call/divert mobile call using Java on desktop?
Thanks!
On a wider note, how to interface with Mobile network using desktop Java? Is it possible?
Could we call/divert mobile call using Java on desktop?
Thanks!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
@samirbhogayta: please check my previous reply. The link that you have posted is the first link that i posted in my previous reply.
ASKER
The solution is useful, but does not answer my original question completely about a free sms service in India. Anyhow, this is probabaly the closest that we can get
Here is some information on sending from Java. The messages are not free, but you do get a free trial account.
http://www.redoxygen.com/developers/java/
Java API
Use this API to send text messages from Java.
Simple HTTP request
Encrypted communication over SSL
Long SMS (up to 765 characters)
Delivery status via function return code
Email replies
Example
public static int SendSMS(String strAccountId,String strEmail,String strPassword,
String strMSISDN,String strMessage,StringBuffer strResponse)
{
String sRequestURL;
String sData;
int nResult = -1;
sRequestURL = "http://www.redoxygen.net/sms.dll?Action=SendSMS";
try
{
sData = ("AccountId=" + URLEncoder.encode(strAccou ntId,"UTF- 8"));
sData += ("&Email=" + URLEncoder.encode(strEmail ,"UTF-8")) ;
sData += ("&Password=" + URLEncoder.encode(strPassw ord,"UTF-8 "));
sData += ("&Recipient=" + URLEncoder.encode(strMSISD N,"UTF-8") );
sData += ("&Message=" + URLEncoder.encode(strMessa ge,"UTF-8" ));
URL urlObject = new URL(sRequestURL);
HttpURLConnection con = (HttpURLConnection) urlObject.openConnection() ;
con.setRequestMethod("POST ");
con.setDoInput (true);
con.setDoOutput (true);
DataOutputStream out;
out = new DataOutputStream(con.getOu tputStream ());
out.writeBytes (sData);
out.flush();
out.close();
BufferedReader in = new BufferedReader(new InputStreamReader(con.getI nputStream ()));
String inputLine;
StringBuffer responseBuffer = new StringBuffer();
while ((inputLine = in.readLine()) != null)
{
responseBuffer = responseBuffer.append(inpu tLine);
responseBuffer = responseBuffer.append("\n\ n\n");
}
strResponse.replace(0,0,re sponseBuff er.toStrin g());
String sResultCode = strResponse.substring(0,4) ;
nResult = Integer.parseInt(sResultCo de);
in.close();
}
catch (Exception e)
{
System.out.println("Except ion caught sending SMS\n");
nResult = -2;
}
return nResult;
}
http://www.redoxygen.com/developers/java/
Java API
Use this API to send text messages from Java.
Simple HTTP request
Encrypted communication over SSL
Long SMS (up to 765 characters)
Delivery status via function return code
Email replies
Example
public static int SendSMS(String strAccountId,String strEmail,String strPassword,
String strMSISDN,String strMessage,StringBuffer strResponse)
{
String sRequestURL;
String sData;
int nResult = -1;
sRequestURL = "http://www.redoxygen.net/sms.dll?Action=SendSMS";
try
{
sData = ("AccountId=" + URLEncoder.encode(strAccou
sData += ("&Email=" + URLEncoder.encode(strEmail
sData += ("&Password=" + URLEncoder.encode(strPassw
sData += ("&Recipient=" + URLEncoder.encode(strMSISD
sData += ("&Message=" + URLEncoder.encode(strMessa
URL urlObject = new URL(sRequestURL);
HttpURLConnection con = (HttpURLConnection) urlObject.openConnection()
con.setRequestMethod("POST
con.setDoInput (true);
con.setDoOutput (true);
DataOutputStream out;
out = new DataOutputStream(con.getOu
out.writeBytes (sData);
out.flush();
out.close();
BufferedReader in = new BufferedReader(new InputStreamReader(con.getI
String inputLine;
StringBuffer responseBuffer = new StringBuffer();
while ((inputLine = in.readLine()) != null)
{
responseBuffer = responseBuffer.append(inpu
responseBuffer = responseBuffer.append("\n\
}
strResponse.replace(0,0,re
String sResultCode = strResponse.substring(0,4)
nResult = Integer.parseInt(sResultCo
in.close();
}
catch (Exception e)
{
System.out.println("Except
nResult = -2;
}
return nResult;
}
ASKER
In other words, I would like to send SMS thru internet to a desired number(or a set of numbers)