Java Send SMS SMS implementation interface

Source: Internet
Author: User

Import java.io.UnsupportedEncodingException;
Import Org.apache.commons.httpclient.Header;
Import org.apache.commons.httpclient.HttpClient;
Import Org.apache.commons.httpclient.NameValuePair;
Import Org.apache.commons.httpclient.methods.PostMethod;

public class Sendmsg_webchinese {

public static void Main (string[] args) throws Exception
{

HttpClient client = new HttpClient ();
Postmethod post = new Postmethod ("http://gbk.sms.webchinese.cn");  
Post.addrequestheader ("Content-type", " APPLICATION/X-WWW-FORM-URLENCODED;CHARSET=GBK ");//Set transcoding
namevaluepair[] Data ={new Namevaluepair (" Uid "in the header file," Site user name "), New Namevaluepair (" Key "," Interface Security password "), New Namevaluepair (" Smsmob "," mobile phone number "), New Namevaluepair (" Smstext "," 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 ); Print return message status


Post.releaseconnection ();

}

}

Jar Package Download
Commons-logging-1.1.1.jar
Commons-httpclient-3.1.jar
Commons-codec-1.4.jar

Java Send SMS SMS implementation interface

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.