Now the Chinese network is built to register a own account,
Then there is the code case, and the corresponding download jar package address
The code is as follows:
public class Message {
public static void Main (string[] args) {
try {
New Message (). SendMessage ();
} catch (HttpException e) {
E.printstacktrace ();
} catch (IOException e) {
E.printstacktrace ();
}
}
public void SendMessage () throws HttpException, ioexception{
HttpClient client = new HttpClient ();
Postmethod post = new Postmethod ("http://gbk.api.smschinese.cn");
Set transcoding in the header file
Post.addrequestheader ("Content-type", "APPLICATION/X-WWW-FORM-URLENCODED;CHARSET=GBK");
namevaluepair[] data = {
New Namevaluepair ("Uid", "Thestar"),
New Namevaluepair ("Key", "73d1e45fd5f0fa2b9a87"),
New Namevaluepair ("Smsmob", "18324121564"),
New Namevaluepair ("Smstext", "Captcha: 6699")
};
Post.setrequestbody (data);
Client.executemethod (POST);
header[] headers = post.getrequestheaders ();
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);//print return message status
Post.releaseconnection ();
}
}
Java implementation of simple SMS send