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

Steps to realize short message group sending with JAVA;

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

}

}