Package com.bcloud.msg.http;
Import Java.io.ByteArrayOutputStream;
Import Java.io.InputStream;
Import Java.net.URLDecoder;
Import org.apache.commons.httpclient.HttpClient;
Import Org.apache.commons.httpclient.HttpStatus;
Import Org.apache.commons.httpclient.NameValuePair;
Import Org.apache.commons.httpclient.URI;
Import Org.apache.commons.httpclient.methods.GetMethod;
/** * * @param URL app address, similar to http://ip:port/msg/* @param account * @param pswd password * @param mobile phone number, multiple numbers using "," Split * @p Aram MSG Message content * @param needstatus requires a status report, requires true, does not require false * @return return value definition see HTTP protocol documentation * @throws Exception */public static S Tring batchsend (string URL, string account, String pswd, String Mobile, String msg, Boolean needstatus, String Extn O) throws Exception {HttpClient client = new HttpClient (); GetMethod method = new GetMethod (); try {uri base = new Uri (URL, false); Method.seturi (new URI (Base, "HTTPBATCHSENDSM", false)); Method.setquerystring (new namevaluepair[] {new Namevaluepair ("account", account), new Name Valuepair ("pswd", pswd), New Namevaluepair ("mobile", mobile), New Namevaluepair ("Needstatus ", String.valueof (Needstatus)), New Namevaluepair (" MSG ", msg), New Namevaluepair (" Extno ", E Xtno),}); int result = ClienT.executemethod (method); if (result = = HTTPSTATUS.SC_OK) {InputStream in = Method.getresponsebodyasstream (); Bytearrayoutputstream BAOs = new Bytearrayoutputstream (); byte[] buffer = new byte[1024]; int len = 0; while (len = in.read (buffer))! =-1) {baos.write (buffer, 0, Len); } return Urldecoder.decode (Baos.tostring (), "UTF-8"); } else {throw new Exception ("HTTP ERROR Status:" + method.getstatuscode () + ":" + Method.getstatustext ()); }} finally {method.releaseconnection (); }}
}
"Java" How to get the Blue 253 SMS verification code?