send sms demo

master
3y 4 years ago
parent e66101b6c3
commit ad6543a0e2

@ -11,14 +11,17 @@ import com.tencentcloudapi.common.profile.HttpProfile;
import com.tencentcloudapi.sms.v20210111.SmsClient;
import com.tencentcloudapi.sms.v20210111.models.SendSmsRequest;
import com.tencentcloudapi.sms.v20210111.models.SendSmsResponse;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Service;
/**
* @author 3y
* @date 2021/11/6
* 1. https://cloud.tencent.com/document/api/382/55981
* 2. 使SDK
* 2. 使SDK
* 3. 使API Explorer
*/
@Service
@ -32,13 +35,23 @@ public class TencentSmsScript {
private static final String REGION = "ap-guangzhou";
/**
* TODO
*
*/
private final static String SECRET_ID = "//";
private final static String SECRET_KEY = "//";
private static final String SMS_SDK_APP_ID = "//";
private static final String TEMPLATE_ID = "//";
private static final String SIGN_NAME = "//";
@Value("${tencent.sms.account.secret-id}")
private String SECRET_ID;
@Value("${tencent.sms.account.secret-key}")
private String SECRET_KEY;
@Value("${tencent.sms.account.sms-sdk-app-id}")
private String SMS_SDK_APP_ID;
@Value("${tencent.sms.account.template-id}")
private String TEMPLATE_ID;
@Value("${tencent.sms.account.sign_name}")
private String SIGN_NAME;
public String send(SmsParam smsParam) {
try {

@ -22,12 +22,19 @@ public class AustinApplication {
SpringApplication.run(AustinApplication.class, args);
}
@GetMapping("/hello")
public String hello() {
/**
* @param phone
* @return
*/
@GetMapping("/sendSms")
public String sendSms(String phone,String content) {
/**
* content
*/
SmsParam smsParam = SmsParam.builder()
.phones(new HashSet<>(Arrays.asList("//TODO PHONE ")))
.content("3333")
.phones(new HashSet<>(Arrays.asList(phone)))
.content(content)
.build();
return tencentSmsScript.send(smsParam);

@ -1,6 +0,0 @@
# ok http配置信息 TODO
ok.http.connect-timeout=30
ok.http.read-timeout=30
ok.http.write-timeout=30
ok.http.max-idle-connections=200
ok.http.keep-alive-duration=300

@ -0,0 +1,18 @@
# HTTP 连接配置 TODO
ok:
http:
connect-timeout: 30
keep-alive-duration: 300
max-idle-connections: 200
read-timeout: 30
write-timeout: 30
# 腾讯云账号相关的信息配置 TODO
tencent:
sms:
account:
secret-id:
secret-key:
sign_name:
sms-sdk-app-id:
template-id:

@ -4,7 +4,7 @@
<contextName>austin</contextName>
<!-- 设置日志输出路径 可以使“${}”来使用变量。TODO 这里后面是需要读配置的 -->
<!-- 设置日志输出路径 可以使“${}”来使用变量。TODO 后面是可以读配置的 -->
<property name="log.path" value="logs"/>

Loading…
Cancel
Save