mirror of
https://gitee.com/dromara/sms4j.git
synced 2025-12-08 01:48:38 +08:00
修复容联云短信发送失败的问题
This commit is contained in:
parent
76cb93c4cc
commit
2763b2b70f
@ -20,24 +20,6 @@ public class CloopenConfig extends BaseConfig {
|
|||||||
*/
|
*/
|
||||||
private String baseUrl = "https://app.cloopen.com:8883/2013-12-26";
|
private String baseUrl = "https://app.cloopen.com:8883/2013-12-26";
|
||||||
|
|
||||||
/**
|
|
||||||
* Rest URL 域名
|
|
||||||
*
|
|
||||||
* @see #baseUrl
|
|
||||||
* @deprecated v2.0.1
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
private String serverIp;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Rest URL 端口
|
|
||||||
*
|
|
||||||
* @see #baseUrl
|
|
||||||
* @deprecated v2.0.1
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
private String serverPort;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取供应商
|
* 获取供应商
|
||||||
*
|
*
|
||||||
|
|||||||
@ -59,7 +59,7 @@ public class CloopenSmsImpl extends AbstractSmsBlend<CloopenConfig> {
|
|||||||
CloopenHelper helper = new CloopenHelper(getConfig(), http);
|
CloopenHelper helper = new CloopenHelper(getConfig(), http);
|
||||||
Map<String, Object> paramMap = new LinkedHashMap<>(4);
|
Map<String, Object> paramMap = new LinkedHashMap<>(4);
|
||||||
paramMap.put("to", String.join(",", phones));
|
paramMap.put("to", String.join(",", phones));
|
||||||
paramMap.put("appId", getConfig().getAccessKeyId());
|
paramMap.put("appId", getConfig().getSdkAppId());
|
||||||
paramMap.put("templateId", templateId);
|
paramMap.put("templateId", templateId);
|
||||||
paramMap.put("datas", messages.keySet().stream().map(messages::get).toArray(String[]::new));
|
paramMap.put("datas", messages.keySet().stream().map(messages::get).toArray(String[]::new));
|
||||||
return helper.smsResponse(paramMap);
|
return helper.smsResponse(paramMap);
|
||||||
|
|||||||
@ -67,3 +67,10 @@ sms:
|
|||||||
appKey: d42d7
|
appKey: d42d7
|
||||||
mchId: 100
|
mchId: 100
|
||||||
signName: 【test】
|
signName: 【test】
|
||||||
|
cloopen:
|
||||||
|
# 短信厂商
|
||||||
|
supplier: cloopen
|
||||||
|
base-url: https://app.cloopen.com:8883/2013-12-26
|
||||||
|
access-key-id: 你的Access Key
|
||||||
|
access-key-secret: 你的Access Key Secret
|
||||||
|
sdkAppId: 你的应用ID
|
||||||
@ -2,6 +2,7 @@ package org.dromara.sms4j.example;
|
|||||||
|
|
||||||
import cn.hutool.core.collection.ListUtil;
|
import cn.hutool.core.collection.ListUtil;
|
||||||
import cn.hutool.core.lang.Assert;
|
import cn.hutool.core.lang.Assert;
|
||||||
|
import cn.hutool.core.map.MapUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.hutool.json.JSONUtil;
|
import cn.hutool.json.JSONUtil;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@ -15,6 +16,7 @@ import org.junit.jupiter.api.Test;
|
|||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@SpringBootTest
|
@SpringBootTest
|
||||||
@ -23,7 +25,7 @@ class Sms4jTest {
|
|||||||
/**
|
/**
|
||||||
* 填测试手机号
|
* 填测试手机号
|
||||||
*/
|
*/
|
||||||
private static final String PHONE = "";
|
private static final String PHONE = "18822266727";
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void byLoadTest() {
|
public void byLoadTest() {
|
||||||
@ -59,7 +61,11 @@ class Sms4jTest {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 容联云
|
// 容联云
|
||||||
SmsResponse smsResponse = SmsFactory.getBySupplier(SupplierConstant.CLOOPEN).sendMessage(PHONE, SmsUtils.getRandomInt(6));
|
Map<String, String> messageMap = MapUtil.newHashMap(2, true);
|
||||||
|
messageMap.put("captcha", SmsUtils.getRandomInt(4));
|
||||||
|
messageMap.put("expirationInMinutes", "5");
|
||||||
|
SmsResponse smsResponse = SmsFactory.getBySupplier(SupplierConstant.CLOOPEN)
|
||||||
|
.sendMessage(PHONE, "1", (LinkedHashMap<String, String>) messageMap);
|
||||||
log.info(JSONUtil.toJsonStr(smsResponse));
|
log.info(JSONUtil.toJsonStr(smsResponse));
|
||||||
Assert.isTrue(smsResponse.isSuccess());
|
Assert.isTrue(smsResponse.isSuccess());
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user