I have received this javascript code from the bulksms vendor and want to add it to a dialog2 component.
1. Would it be possible to run this from the dialog2 component
2. If possible, is there someone who can assist me with this as I am clueless on this javascript code.
3. I have created a username, password and message objects but from there I am not sure.
Thanks
1. Would it be possible to run this from the dialog2 component
2. If possible, is there someone who can assist me with this as I am clueless on this javascript code.
3. I have created a username, password and message objects but from there I am not sure.
Thanks
Code:
java code: import java.net.*; import java.io.*; public class SendSms { static public void main(String[] args) { try { // Construct data String data = ""; /* * Note the suggested encoding for certain parameters, notably * the username, password and especially the message. ISO-8859-1 * is essentially the character set that we use for message bodies, * with a few exceptions for e.g. Greek characters. For a full list, * see: http://bulksms.2way.co.za/docs/eapi/submission/character_encoding/ */ data += "username=" + URLEncoder.encode("myusername", "ISO-8859-1"); data += "&password=" + URLEncoder.encode("xxxxxx", "ISO-8859-1"); data += "&message=" + URLEncoder.encode("This is a test", "ISO-8859-1"); data += "&want_report=1"; data += "&msisdn=44123123123"; // Send data URL url = new URL("http://bulksms.2way.co.za:5567/eapi/submission/send_sms/2/2.0"); /* * If your firewall blocks access to port 5567, you can fall back to port 80: * URL url = new URL("http://bulksms.2way.co.za/eapi/submission/send_sms/2/2.0"); * (See FAQ for more details.) */ URLConnection conn = url.openConnection(); conn.setDoOutput(true); OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream()); wr.write(data); wr.flush(); // Get the response BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream())); String line; while ((line = rd.readLine()) != null) { // Print the response output... System.out.println(line); } wr.close(); rd.close(); } catch (Exception e) { e.printStackTrace(); } } }
Comment