修复网易云短信发送失败bug,并更改版本号为3.0

This commit is contained in:
tiejiaxiaobao 2023-08-26 12:47:58 +08:00
parent db8d699d19
commit 230e3113e6
2 changed files with 4 additions and 13 deletions

View File

@ -97,15 +97,7 @@ public class NeteaseSmsImpl extends AbstractSmsBlend {
String nonce = IdUtil.fastSimpleUUID();
String curTime = String.valueOf(DateUtil.currentSeconds());
String checkSum = NeteaseUtils.getCheckSum(config.getAccessKeySecret(), nonce, curTime);
Map<String, String> body = new LinkedHashMap<>(4);
body.put("templateid", templateId);
JSONArray jsonArray = JSONUtil.createArray();
JSONArray messageArray = JSONUtil.createArray();
messageArray.add(message);
jsonArray.addAll(phones);
body.put("mobiles", jsonArray.toString());
body.put("params", messageArray.toString());
body.put("needUp", config.getNeedUp().toString());
Map<String, String> body = NeteaseUtils.generateParamMap(config, phones, message, templateId);
String paramStr = NeteaseUtils.generateParamBody(body);
try(HttpResponse response = HttpRequest.post(requestUrl)
.header("Content-Type", "application/x-www-form-urlencoded")

View File

@ -78,14 +78,13 @@ public class NeteaseUtils {
return sortQueryString.substring(1);
}
private static Map<String, String> generateParamMap(NeteaseConfig neteaseConfig, List<String> phone, String message, String templateId) {
Map<String, String> paramMap = new HashMap<>();
public static Map<String, String> generateParamMap(NeteaseConfig neteaseConfig, List<String> phone, String message, String templateId) {
Map<String, String> paramMap = new HashMap<>(4);
JSONArray messageArray = JSONUtil.createArray();
messageArray.add(message);
JSONArray phoneArray = JSONUtil.createArray();
phoneArray.add(phone);
phoneArray.addAll(phone);
paramMap.put("mobiles", phoneArray.toString());
paramMap.put("SignName", neteaseConfig.getSignature());
paramMap.put("params", messageArray.toString());
paramMap.put("templateid", templateId);
paramMap.put("needUp", neteaseConfig.getNeedUp().toString());