1. SMS
SMS is an application provided by China Internet. It is generally used for enterprise users. This blog article describes how to write the simplest Hello World Java program to send text messages to a specified mobile phone number. SMS is a commercial application that requires registration of users and provides only five free SMS messages and three free MMS sending opportunities. The excess part must be recharged before it can be used.
2. register an SMS user
Log on to the http://sms.webchinese.cn website, register the user, remember to save the interface security password, used for programming. Assume that the user name we registered is "poechant" and the interface security password is "1234abcd5678efgh ".
3. SMS sending Interface
(1) GBK-encoded sending interface address:
Http://gbk.sms.webchinese.cn /? Uid = user name on this site & Key = API security password & smsmob = Mobile Phone Number & smstext = SMS content
(2) UTF-8 encoding sending interface address:
Http://utf8.sms.webchinese.cn /? Uid = user name on this site & Key = API security password & smsmob = Mobile Phone Number & smstext = SMS content
(3) API address for obtaining the number of text messages (utf8 ):
Http://sms.webchinese.cn/web_api/SMS? Action = sms_num & uid = user name on this site & Key = interface Security Password
(4) API address for obtaining the number of SMS messages (GBK ):
Http://sms.webchinese.cn/web_api/SMS/GBK? Action = sms_num & uid = user name on this site & Key = interface Security Password
4. Java library used
You can use a commons-httpclient.jar that relies on commons-codec.jar and commons-logging.jar. Therefore, it is recommended to download:
Commons-codec-1.4.jar
Commons-logging-1.1.1.jar
Commons-httpclient-3.1.jar
Note: but the current commons-httpclient-3.1.jar does not exist, its implementation of the function, has been added to the httpcomponents-client Apache project.
5. instance program:
Package COM. sinosuperman. SMS; 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 test {public static void main (string [] ARGs) throws exception {httpclient client = new httpclient (); postmethod post = new postmethod ("http://gbk.sms.webchinese.c N "); Post. addrequestheader ("Content-Type", "application/X-WWW-form-urlencoded; charset = GBK "); // set transcoding namevaluepair [] DATA = {New namevaluepair ("uid", "poechant"), new namevaluepair ("key", "1234abcd5678efgh") in the header file "), new namevaluepair ("smsmob", "12345678901"), new namevaluepair ("smstext", "China Mobile representative XX reminds you to have a good meal as soon as possible! "Zookeeper implements post.setrequestbody(dataworkflow implements client.exe cutemethod (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); Post. releaseconnection ();}}
6. Network Management Selection
You can select three types: Default Gateway, 106 network management (with signature), and advertisement network management.
7. Usage
(1) Send an advertisement text message to a stranger. Please switch to the advertising gateway to send the message. If the message is found, use the 106 gateway to send an immediate seal;
(2) 106 the gateway does not allow advertisements to strangers; otherwise, the seal number may be used to send messages to old customers, members, or employees;
(3) 106 industry gateway independent contact customer service, large volume of activation.
(4) All the messages sent by the gateway to IOT platform and the mobile phone of telecom users are sent by the 106 gateway.
(5) The ad gateway uses the 106 gateway to simulate the mobile phone number, which is an empty number, with a latency arrival rate of 99% in some periods;