点击注册后进行登录 页面如下图所示很是简洁,也省去了很多复杂的流程
需要进行充值
价格相对公道,个人开发测试完全够用
我的应用中有后续开发要用到的AppId和AppSecret
短信模板中可以根据个人需要进行编辑但是要进行审核
后续开发中需要用到模版的ID
在官网的开发文档中有SDK开发文档
文章目录
一、在Spring boot工程中创建一个发送验证码的API
1.创建一个新的Maven 模块
2.引入相关依赖
3.编写配置文件
server:
port: 8223
spring:
profiles:
active: dev
application:
name: service-sms
# redis数据库配置
redis:
host: 127.0.0.1
port: 6379
timeout: 3000ms
lettuce:
pool:
max-idle: 5
min-idle: 0
# nacos配置
cloud:
nacos:
discovery:
server-addr: localhost:8848 # nacos服务地址
# 远程服务调用
feign:
client:
config:
default:
connectTimeout: 10000 #连接超时配置
readTimeout: 600000 #执行超时配置
# 如果想要使用配置文件进行 榛子云配置 可以像下方这样
zhenziyun:
sms:
file:
apiUrl: 你的apiUrl
appId: 你的appId
appSecret: 你的appSecret
templateId: 你的短信模版
4.创建启动类以及添加随机数生成工具类
@SpringBootApplication(exclude= {
DataSourceAutoConfiguration.class})
@EnableFeignClients
@ComponentScan("com.ts")
public class SmsApplication {
public static void main(String[] args) {
SpringApplication.run(SmsApplication.class,args);
}
}
public class RandomUtils {
private static final Random random = new Random();
private static final DecimalFormat fourdf = new DecimalFormat("0000");
private static final DecimalFormat sixdf = new DecimalFormat("000000");
public static String getFourBitRandom() {
return fourdf.format(random.nextInt(10000));
}
public static String getSixBitRandom() {
return sixdf.format(random.