亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

通過(guò)第三方接口發(fā)送短信驗(yàn)證碼/短信通知(推薦)

 更新時(shí)間:2016年08月29日 16:13:03   作者:gaochaojs  
這篇文章主要介紹了通過(guò)第三方接口發(fā)送短信驗(yàn)證碼/短信通知(推薦)的相關(guān)資料,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友可以參考下

需求:將首次交付密碼為公共默認(rèn)密碼的方式改為點(diǎn)擊入職功能,用短信方式發(fā)送系統(tǒng)自動(dòng)生成的八位含數(shù)字、大小寫(xiě)字母和特殊符號(hào)生成的密碼。短信發(fā)送服務(wù)由云通信http://www.yuntongxun.com/提供。

隨機(jī)密碼生成方法:

/**
* 生成隨即密碼
* @author chao.gao
* @param pwd_len 生成的密碼的總長(zhǎng)度
* @return 密碼的字符串
*/
public static String genRandomNum(int pwd_len) {
// String re="(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[!@#$%^&]).{10,}";
String regex = "^(?![0-9]+$)(?![a-zA-Z]+$)[A-Za-z0-9@#$%]{8,16}$";
//35是因?yàn)閿?shù)組是從0開(kāi)始的,26個(gè)字母+10個(gè)數(shù)字
final int maxNum = 26;
int i; //生成的隨機(jī)數(shù)
int count = 0; //生成的密碼的長(zhǎng)度
char[] str = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k',
'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w',
'x', 'y', 'z'};
char[] upChar = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K',
'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
'X', 'Y', 'Z'};
char[] numChar = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};
char[] speChar = {'!', '@', '#', '$', '%'};
StringBuffer pwd = new StringBuffer("");
Random r = new Random();
while (count < 2) {
//生成隨機(jī)數(shù),取絕對(duì)值,防止生成負(fù)數(shù),
i = Math.abs(r.nextInt(maxNum)); //生成的數(shù)最大為36-1
if (i >= 0 && i < str.length) {
pwd.append(str[i]);
count++;
}
}
count=0;
while (count < 2) {
//生成隨機(jī)數(shù),取絕對(duì)值,防止生成負(fù)數(shù),
i = Math.abs(r.nextInt(7)); //生成的數(shù)最大為7-1
if (i >= 0 && i < upChar.length) {
pwd.append(upChar[i]);
count++;
}
}
count=0;
while (count < 2) {
//生成隨機(jī)數(shù),取絕對(duì)值,防止生成負(fù)數(shù),
i = Math.abs(r.nextInt(maxNum)); //生成的數(shù)最大為10-1
if (i >= 0 && i < numChar.length) {
pwd.append(numChar[i]);
count++;
}
}
count=0;
while (count < 2) {
//生成隨機(jī)數(shù),取絕對(duì)值,防止生成負(fù)數(shù),
i = Math.abs(r.nextInt(maxNum)); //生成的數(shù)最大為10-1
if (i >= 0 && i < speChar.length) {
pwd.append(speChar[i]);
count++;
}
}
return pwd.toString();
}

發(fā)送短信接口:(jar包見(jiàn)附件)

參考:

https://www.yuntongxun.com/doc/rest/sms/3_2_2_3.html

public class SDKTestSendTemplateSMS {
public static void main(String[] args) {
HashMap<String, Object> result = null; 
CCPRestSDK restAPI = new CCPRestSDK();
restAPI.init("app.cloopen.com", "8883");
// 初始化服務(wù)器地址和端口,生產(chǎn)環(huán)境配置成app.cloopen.com,端口是8883. 
restAPI.setAccount("accountSid", "accountToken");
// 初始化主賬號(hào)名稱(chēng)和主賬號(hào)令牌,登陸云通訊網(wǎng)站后,可在"控制臺(tái)-應(yīng)用"中看到開(kāi)發(fā)者主賬號(hào)ACCOUNT SID和 
主賬號(hào)令牌AUTH TOKEN。
restAPI.setAppId("AppId");
// 初始化應(yīng)用ID,如果是在沙盒環(huán)境開(kāi)發(fā),請(qǐng)配置"控制臺(tái)-應(yīng)用-測(cè)試DEMO"中的APPID。
//如切換到生產(chǎn)環(huán)境,請(qǐng)使用自己創(chuàng)建應(yīng)用的APPID
result = restAPI.sendTemplateSMS("號(hào)碼1,號(hào)碼2等","模板Id" ,new String[]{"模板內(nèi)容1","模板內(nèi)容2"});
System.out.println("SDKTestGetSubAccounts result=" + result); 
if("000000".equals(result.get("statusCode"))){
//正常返回輸出data包體信息(map)
HashMap<String,Object> data = (HashMap<String, Object>) result.get("data");
Set<String> keySet = data.keySet();
for(String key:keySet){ 
Object object = data.get(key); 
System.out.println(key +" = "+object); 
}
}else{
//異常返回輸出錯(cuò)誤碼和錯(cuò)誤信息
System.out.println("錯(cuò)誤碼=" + result.get("statusCode") +" 錯(cuò)誤信息= "+result.get("statusMsg"));
}
}
}

以上所述是小編給大家介紹的通過(guò)第三方接口發(fā)送短信驗(yàn)證碼/短信通知(推薦),希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!

相關(guān)文章

最新評(píng)論