This article mainly studies the JAVA language to send mobile phones, and shares it with you for your reference. The specific content is as follows
There are several ways to send mobile phone text messages:
(1) Use the webservice interface to send mobile phone text messages. This can be sent using the webservice provided by sina, but registration is required;
(2) Use SMS mao to send SMS. This method should be more commonly used, as long as you need to purchase hardware equipment, haha;
(3) Use the SMS SMS platform provided by China Network Construction. My small demo is sent based on this line.
Note: Java implements sending SMS messages on mobile phone
/*** Description: Java implements sending mobile phone text messages* Author: aa00aa00*/package com.test.mobile; 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://sms.webchinese.cn/web_api/");post.addRequestHeader("Content-Type","application/x-www-form-urlencoded;charset=gbk");// Set transcoding NameValuePair[] data = { new NameValuePair("Uid", "******"), // Registered username new NameValuePair("Key", "******"), // After successful registration, the key used to log in to the website is new NameValuePair("smsMob", "*********", // Mobile phone number new NameValuePair("smsText", "Message sent by java program!!") };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);post.releaseConnection();}} Run the above code: you can send a text message to your phone. I personally test it. There is no problem, so I will share it with you!
The above is all about this article, I hope it will be helpful for everyone to learn Java programming.