【发布时间】:2017-07-09 00:48:35
【问题描述】:
我有一种向群发成员发送短信的方法 这是我的java方法
public void sendSMS(String mobilno,String msg)
{
URLConnection myURLConnection=null;
URL myURL=null;
BufferedReader reader=null;
String mainUrl="http://smsstreet.in/websms/sendsms.aspx?userid=id&password=pwd&sender=sender&mobileno="+mobilno+"&msg="+msg;
StringBuilder sbPostData= new StringBuilder(mainUrl);
mainUrl = sbPostData.toString();
try
{
myURL = new URL(mainUrl);
myURLConnection = myURL.openConnection();
myURLConnection.connect();
reader= new BufferedReader(new InputStreamReader(myURLConnection.getInputStream()));
String response;
while ((response = reader.readLine()) != null)
System.out.println(response);
reader.close();
}
catch (IOException e)
{
e.printStackTrace();
}
}
这是我的服务:
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
// TODO Auto-generated method stub
String mobilnmbers=request.getParameter("mobName");
System.out.println(mobilnmbers);
String message=request.getParameter("comment");
System.out.println(message);
SMSMethod sms=new SMSMethod();
sms.sendSMS(mobilnmbers, message);
}
当我将它调用到 servlet 时,它会给出以下异常
java.io.IOException: Server returned HTTP response code: 400 for URL: http://smsstreet.in/websms/sendsms.aspx?userid=id&password=pwd&sender=sender&mobileno=9014780300,8309518663,9920221173,9849133273,9849656287,7013083104,8759197399,1234567890,8096613756,7075472796,8121104305,9182176200,9949327590,8309490418,9949913331,8125206381,9550371787,9502167674,9912193234,9912193234,9700237487,9246563935&msg=Have you started booking the train tickets
我是这个 smsGatway 的新手,谁能帮助我?
【问题讨论】:
-
解决办法是什么?
-
尝试去掉
msg中的空格,这可能会导致您的网址格式错误。 -
我怀疑你的网址。您是否与邮递员或类似的客户核实以访问该服务?
-
如果我删除空格消息会不会是不可读的@ Asew