我正在尝试通过批量短信发送网站在手机上发送短信。我正在尝试使用以下代码通过 java api 发送短信。它没有显示任何错误,但没有发送消息。
String urlParameters="usr=username &pwd=1234 &ph=9015569447 &text=Hello";
//String request = "http://hapi.smsapi.org/SendSMS.aspx?";
String request="http://WWW.BULKSMS.FELIXINDIA.COM/send.php?";
try{
URL url = new URL(request);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setDoOutput(true);
connection.setDoInput(true);
connection.setInstanceFollowRedirects(false);
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
connection.setRequestProperty("charset", "utf-8");
connection.setRequestProperty("Content-Length", "" + Integer.toString(urlParameters.getBytes().length));
connection.setUseCaches (false);
DataOutputStream wr = new DataOutputStream(connection.getOutputStream ());
wr.writeBytes(urlParameters);
wr.flush();
wr.close();
connection.disconnect();
}
catch(Exception ex)
{
System.out.print(ex);
}