One, the code
Import Java.io.ioexception;import Org.apache.commons.httpclient.header;import Org.apache.commons.httpclient.httpclient;import Org.apache.commons.httpclient.httpexception;import Org.apache.commons.httpclient.namevaluepair;import Org.apache.commons.httpclient.methods.postmethod;public Class Sendmsg_webchinese {public static void main (string[] args) throws HttpException, IOException {HttpClient client = new Http Client (); Postmethod post = new Postmethod ("http://gbk.sms.webchinese.cn");//Postmethod post = new//Postmethod ("http:// sms.webchinese.cn/web_api/");p ost.addrequestheader (" Content-type "," application/x-www-form-urlencoded;charset= GBK ");//Set transcoding in header file namevaluepair[] data = {new Namevaluepair (" Uid "," Registered user name "),//registered user name New Namevaluepair (" Key "," after registering successfully, Login to the website to get the key "),//After the successful registration, login to the site after the key new Namevaluepair (" Smsmob "," mobile phone number "),//mobile number multiple to", "separated as 12345678900,12365498700new Namevaluepair ("Smstext", "SMS Content")};//SMS Content post.setrequestbody (data); Client.executemethod (POST); header[] headers = Post.getrespoNseheaders (); int statusCode = Post.getstatuscode (); System.out.println ("StatusCode:" + StatusCode); for (Header h:headers) {System.out.println ("---" + h.tostring ());} string result = new String (post.getresponsebodyasstring (). GetBytes ("GBK")); SYSTEM.OUT.PRINTLN (result);}}Second, the project needs the jar package
Commons-logging-1.1.1.jar
: Http://pan.baidu.com/s/1CSonc
Commons-httpclient-3.1.jar
: http://pan.baidu.com/s/1sjjXy6x
Commons-codec-1.4.jar
: Http://pan.baidu.com/s/1eQGhVhS
Java sends messages to your phone via code