DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Send Sms (worldwide) Using Www.smsmatrix.com In Java

07.29.2010
| 2666 views |
  • submit to reddit
        Send sms (worldwide) using www.smsmatrix.com.
More examples at <a href="http://www.smsmatrix.com/?sms-gateway">SMS Gateway</a> page.

try
{
 String MATRIXURL = "http://www.smsmatrix.com/matrix";
 String PHONE = "12506063167";
 String USERNAME = "user@hotmail.com";
 String PASSWORD = "pass72727";
 String TXT = "This is a test, pls ignore";

 String q = "username=" + URLEncoder.encode (USERNAME, "UTF-8");
 q += "&" + "password=" + URLEncoder.encode (PASSWORD, "UTF-8");
 q += "&" + "phone=" + PHONE;
 q += "&" + "txt=" + URLEncoder.encode (TXT, "UTF-8");

 URL url = new URL (MATRIXURL);
 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 ("Matrix API Response :");
 while ((line = rd.readLine()) != null) { System.out.println (line); }
 wr.close();
 rd.close();
} catch (Exception e) { }