SMS Interface - java

Client interface section provides https and WebService (currently only supports text messages submitted) interfaces, customers can select the appropriate interfaces according to the needs, interfaces default encoding using UTF-8

Send Rules:

The same number, transmitting content with (codes), only three within three minutes,

More than three, the system will default to (bad faith)

You can only send 10 messages within the same number, the system default day, more than

10 gauge will fail (special numbers, or special customer needs to find the customer service process)

Note: SMS billing number of text messages with words, generally 70 characters of text messages a billing. Over 70 words long message to be divided, charging a 67-word, for example; 71 short word length is two SMS billing, billing 134 is two words (67 * 2). 135 words billing 3, and so on.
The first chapter SMS Interface
1.1 request address
request url address is the address of the client request to call interface program, using the https post interface address is

https://dx.ipyy.net/sms.aspx corresponding to UTF-8

https://dx.ipyy.net/smsGBK.aspx corresponds GB2312

https://dx.ipyy.net/smsJson.aspx corresponding to UTF-8 (the return value json format)

https://dx.ipyy.net/ensms.ashx corresponding to UTF-8 (encrypted transmission, use json)

General entry address does not change, when the change occurs, it will notify the user interfaces 

private static CloseableHttpClient client;
  String sendVerificationCode public (String Phone) { 

Final the Url String = "https://dx.ipyy.net/ensms.ashx";

// user ID.
UserId = String "59833";
// user account name
String userName = "9M00031";
// Interface password
String password = "9M0003121";

// target phone number, more than half angle "," to separate
String = Mobile Phone;
String = String.valueOf CodeStr (. (new new Random () nextInt (899999) + 100000));

// content
String content = "[xxxxxx] your verification code is:" + CodeStr + ", the effective time of five minutes";

// extension number, not leave empty
String EXT = "";

// Leave blank instant messaging, text messaging specify the timing, format: yyyy-mM-dd HH: mm:

String stamp = new SimpleDateFormat("MMddHHmmss").format(new Date());
String secret = MD5.GetMD5Code(password + stamp).toUpperCase();

try {
JSONObject jsonObj = new JSONObject();
jsonObj.put("UserName", userName);
jsonObj.put("Stamp", stamp);
jsonObj.put("Secret", secret);
jsonObj.put("Moblie", mobile);
jsonObj.put("Text", content);
jsonObj.put("Ext", ext);
jsonObj.put("SendTime", sendTime);

//Des加密,base64转码
String text64 = DesHelper.Encrypt(jsonObj.toString(), password);
client = SSLClient.createSSLClientDefault();
HttpPost post = new HttpPost(Url);
post.setHeader("Content-type", "application/x-www-form-urlencoded;charset=utf-8");
List<NameValuePair> nvps = new ArrayList<NameValuePair>();
nvps.add(new BasicNameValuePair("UserId", userId));
nvps.add(new BasicNameValuePair("Text64", text64));
post.setEntity(new UrlEncodedFormEntity(nvps));
HttpResponse response = client.execute(post);

HttpEntity entity = response.getEntity();
String returnString = EntityUtils.toString(entity, "UTF-8");
// System.out.println(returnString);
EntityUtils.consume(entity);

} catch (Exception ex) {
// System.out.println(ex.getMessage());
}
return CodeStr;
}

 

Guess you like

Origin www.cnblogs.com/wen-/p/12422217.html