Send SMS vis SMS Gateway using Java


/ Published in: Java
Save to your folder(s)



Copy this code and paste it in your HTML
  1. try
  2. {
  3. String MATRIXURL = "http://www.smsmatrix.com/matrix";
  4. String PHONE = "12506063167";
  5. String USERNAME = "[email protected]";
  6. String PASSWORD = "pass72727";
  7. String TXT = "This is a test, pls ignore";
  8.  
  9. String q = "username=" + URLEncoder.encode (USERNAME, "UTF-8");
  10. q += "&" + "password=" + URLEncoder.encode (PASSWORD, "UTF-8");
  11. q += "&" + "phone=" + PHONE;
  12. q += "&" + "txt=" + URLEncoder.encode (TXT, "UTF-8");
  13.  
  14. URL url = new URL (MATRIXURL);
  15. URLConnection conn = url.openConnection();
  16. conn.setDoOutput (true);
  17. OutputStreamWriter wr = new OutputStreamWriter (conn.getOutputStream());
  18. wr.write (q);
  19. wr.flush();
  20.  
  21. BufferedReader rd = new BufferedReader (new InputStreamReader (conn.getInputStream()));
  22. String line;
  23. System.out.println ("Matrix API Response :");
  24. while ((line = rd.readLine()) != null) { System.out.println (line); }
  25. wr.close();
  26. rd.close();
  27. } catch (Exception e) { }

URL: http://www.smsmatrix.com/?sms-gateway

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.