JAVA SMS Script, bulk sms script, sms script
Today Bulksms Offer

Send SMS with JAVA SMS Script

JAVA SMS messaging is one of the services we offer. Here we'll show you how to use our SMS gateway in JAVA. Take the SMS JAVA script code below to send SMS via Developers' Central. Simply register for an account, and you will automatically receive 10 FREE SMS credits to try our service.


Code to send SMS in JAVA:

package javaapplication;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;
public class SMSGATEWAYHUB
{
public static String retval="";
public static String SMSSender(String APIKey,String number,String text,String senderid,String fl)
{
String rsp="";
try {
// Construct The Post Data
String data = URLEncoder.encode("APIKey","UTF-8") + "=" + URLEncoder.encode(APIKey, "UTF-8");
data += "&" + URLEncoder.encode("number", "UTF-8") + "=" + URLEncoder.encode(number, "UTF-8");
data += "&" + URLEncoder.encode("text", "UTF-8") + "=" + URLEncoder.encode(text, "UTF-8");
data += "&" + URLEncoder.encode("senderid", "UTF-8") + "=" + URLEncoder.encode(senderid, "UTF-8");
data += "&" + URLEncoder.encode("flashsms", "UTF-8") + "=" + URLEncoder.encode(flashsms, "UTF-8");
data += "&" + URLEncoder.encode("route", "UTF-8") + "=" + URLEncoder.encode(route, "UTF-8");
//Push the HTTP Request
URL url = new URL("http://login.smsgatewayhub.com/api/mt/SendSMS?");
URLConnection conn = url.openConnection();
conn.setDoOutput(true);
OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
wr.write(data);
wr.flush();
//Read The Response
BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String line;
while ((line = rd.readLine()) != null)
{
// Process line...
retval += line;
}
wr.close();
rd.close();
System.out.println(retval);
rsp = retval;
} catch (Exception e) {
e.printStackTrace();
}
return rsp;
}
public static void main(String[] args) {
String response = SMSSender("APIKey", "917024770247", "message", "WEBSMS", "0", "1");
System.out.println(response);
}
}

Please note that some of the above code has been supplied to SMSGATEWAYHUB by clients. As such, accuracy is not guaranteed by SMSGATEWAYHUB.