Wednesday, March 31, 2004 03:56 AM
Yes, there is, but you need to find yourself an SMS provider that has an HTTP interface to their software. If you can find one, you can simply write some code to make an HttpConnection to the remote provider, giving information on the SMS in the query string.
Below is some sample code. The url object contains the full URL to the SMS service provider, including our account user id and password, the SMS number to send to and the message. The first section of the code is to get through our firewall, so if you don't have a firewall, you don't need this.
URL url = "http://www.smsprovider.com?...";
// Set up our authentication
String auth = "username:password";
String smsAuthentication = "Basic " + new sun.misc.BASE64Encoder().encode(auth.getBytes());
System.setProperty("http.proxyHost", getProxyLocation() );
System.setProperty("http.proxyPort", getProxyPort() );
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
// Wierdness. We have to do this otherwise the SMS does not get
// delivered to the phone. I think that this is because the
// operation is a GET, and if we don't actually retrieve the
// information that has been broadcast, the transaction will
// not be complete.
int smsResponse = conn.getResponseCode();