Send Bulk SMS using JAVA code

Send Bulk SMS using JAVA code

Develop SMS API using JAVA Code

This is just an example SMS API code for JAVA Programming Language, please make sure to sanitize data and other security aspects at the time of actual development.

Send Bulk SMS using JAVA

Sample scripts are provided just for reference only, do not develop using the same code.

Download Text File

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
import java.util.Date;
public class BulkSMSGatewayAPI{
    public static void main(String[] args){
        try{
            Date mydate = new Date(System.currentTimeMillis());
            String data = "";
            data += "Type=Individual"; // can be Bulk/Group
            data += "&UserName=YourUsername"; // your Username
            data += "&Password=" + URLEncoder.encode("xxxxxx", "UTF-8"); // your password
            data += "&Message=" + URLEncoder.encode("SMS Gateway message " + mydate.toString(), "UTF - 8 ");
            data += "&To=" + URLEncoder.encode("9xxxxxxxxx", "UTF-8"); // a valid 10 digit phone no.
            data += "&Language=English"; // Can be "OTHER" for UNICODE
            URL url = new URL("https://www.smsgatewaycenter.com/library/send_sms_2.php?" + data);
            HttpURLConnection conn = (HttpURLConnection) url.openConnection();
            conn.setRequestMethod("GET");
            conn.setDoOutput(true);
            conn.setDoInput(true);
            conn.setUseCaches(false); conn.connect();
            BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
            String line;
            StringBuffer buffer = new StringBuffer();
            while((line = rd.readLine()) != null){
                buffer.append(line).append("\n");
            }
            System.out.println(buffer.toString());
            rd.close();
            conn.disconnect();
        }
        catch (Exception e){
            e.printStackTrace();
        }
    }
}

Go Back! SMS Developers API

Save this interesting page on your Favorite Social Media

Premium Bulk SMS Gateway

SMS Pricing

Receive a Call

Services

SMS Business Opportunities

Bulk SMS Know-how


Convinced? Get an estimate. Contact Now!