"Java" How to get the Blue 253 SMS verification code?

Source: Internet
Author: User

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?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.