Joke Collection Website - Public benefit messages - How does java realize the function of sending short messages in groups
How does java realize the function of sending short messages in groups
1. Use the third-party SMS platform service provider to access the SMS service;
2. Call the SMS submission page to send a request;
3. The server submits a sending request to the third-party short message platform;
4. The SMS platform sends the SMS to the user's mobile phone through the operator.
The following is an example of the JAVA SMS verification code interface code of the second-time SMS platform.
Packaging test;
Import java.io.ioexception;
import Java . io . unsupportedencodingexception;
Import java.net.urisyncttaxexception;
Import java.net.urlencoder;
Import org.apache.commons.mons.mons.lang3.stringtutils;
Public class Apis {
//http address of SMS sending interface, please consult customer service.
Private static string URL = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
//encoding format. UTF-8 is used to unify the transmission coding format.
Private static string encoding = "UTF-8 ";;
The public static void main(String[] args) throws IOException, URISyntaxException {
//account number
string account = " * * * * * * * * * * * * * * * * * * * * * ";
//password
string pswd = " * * * * * * * * * * * * * * * * * * * * * ";
//Change it to the mobile phone number you want to send, use it many times, and segment it.
string mobile = " 13 * * * * * * * * * * ";
//Set the content to be sent.
String msg = "Seconds Technology, your verification code is:1234";
SMS call example
system . out . println(APIs . send(account,pswd,mobile,msg));
}
/**
* Send text messages
*
* @param account
* Account
* @param pswd
* pswd
* @param mobile
* Mobile phone number
* @param content
* SMS content
*/
Public static string send (string account, string pswd, string mobile, string msg) {
Name value pair [] data = {new name value pair ("account"),
A new name-value pair ("pswd", pswd),
New name-value pair ("move", move),
A new name-value pair ("msg", msg),
New name-value pairs ("needstatus", "true"),
new NameValuePair("product "," ")};
Returns doPost(url, data);
}
/**
* post function based on HttpClient.
* PH value
* @param url
* submitted URL
*
* @param data
* Submit name-value pair parameters
* @ returns the submit response.
*/
Private static string doPost (string url, name-value pair [] data) (
http client client = new http client();
post method method = new post method(URL);
//method . setrequestheader(" content type ",
//" application/x-www-form-urlencoded; charset = UTF-8 ");
method . setrequestbody(data);
// client.getParams().setContentCharset(“UTF-8”);
client.getParams().setConnectionManagerTimeout( 10000);
Try {
Client.executeMethod (method);
return method . getresponsebodyasstring();
Catch (exception e) {
e . printstacktrace();
}
Returns null
}
}
- Related articles
- China Construction Bank sends bill SMS.
- What should I do if I haven't received the SMS receipt ten days after renewing the loan?
- How to chase Gemini girls
- How to realize short message in Java program
- What other works of Su Dongpo's original works have been circulated in the world? Calligraphy and painting words and so on!
- Are the SMS notifications from those banks free?
- Why can't the glory of the king recharge her phone bill and send a text message? Click Send, and that's it?
- How does WeChat regularly send the same message to the group three times a day? Is there a great god?
- A letter to break up with his girlfriend.
- Network SMS between Xiaomi's mobile phones