2023年7月31日发(作者:)
阿⾥云短信服务(可以尝试容联云)⼀、开通阿⾥云短信服务1.1、开通阿⾥云短信服务1.2、添加签名管理与模板管理注:审批通过后⽅可使⽤1.3、获取⽤户AccessKey⼆、搭建service-msm模块1.1、 搭建service-msm模块sm模块搭建过程参考service-hosp模块1.2、修改配置1、修改
Id=KeyId==jX8D04Dm12I3gGKj345FYSzu0fq8mT3、启动类@SpringBootApplication(exclude = )//取消数据源⾃动配置@EnableDiscoveryClientpublic class ServiceMsmApplication { public static void main(String[] args) { (, args); }}4、配置⽹关#设置路由[3].id=service-msm#设置路由的[3].uri=lb://service-msm#设置路由断⾔,代理servicerId为auth-service的/auth/路径[3].predicates= Path=/*/msm/**三、封装注册短信验证码接⼝1、添加配置类@Componentpublic class ConstantPropertiesUtils implements InitializingBean { @Value("${Id}") private String regionId; @Value("${KeyId}") private String accessKeyId; @Value("${}") private String secret; public static String REGION_Id; public static String ACCESS_KEY_ID; public static String SECRECT; @Override public void afterPropertiesSet() throws Exception { REGION_Id=regionId; ACCESS_KEY_ID=accessKeyId; SECRECT=secret; }}2、封装service接⼝和实现类public interface MsmService { //发送⼿机验证码 boolean send(String phone, String code);}@Servicepublic class MsmServiceImpl implements MsmService { @Override public boolean send(String phone, String code) { //判断⼿机号是否为空 if(y(phone)) { return false; } //整合阿⾥云短信服务 //设置相关参数 DefaultProfile profile = DefaultProfile. getProfile(_Id, _KEY_ID, T); IAcsClient client = new DefaultAcsClient(profile); CommonRequest request = new CommonRequest(); //tocol(); hod(); ain(""); sion("2017-05-25"); ion("SendSms"); //⼿机号 ryParameter("PhoneNumbers", phone); //签名名称 ryParameter("SignName", "我的⾕粒在线教育⽹站"); //模板code ryParameter("TemplateCode", "SMS_180051135"); //验证码 使⽤json格式 {"code":"123456"} Map
2023年7月31日发(作者:)
阿⾥云短信服务(可以尝试容联云)⼀、开通阿⾥云短信服务1.1、开通阿⾥云短信服务1.2、添加签名管理与模板管理注:审批通过后⽅可使⽤1.3、获取⽤户AccessKey⼆、搭建service-msm模块1.1、 搭建service-msm模块sm模块搭建过程参考service-hosp模块1.2、修改配置1、修改
Id=KeyId==jX8D04Dm12I3gGKj345FYSzu0fq8mT3、启动类@SpringBootApplication(exclude = )//取消数据源⾃动配置@EnableDiscoveryClientpublic class ServiceMsmApplication { public static void main(String[] args) { (, args); }}4、配置⽹关#设置路由[3].id=service-msm#设置路由的[3].uri=lb://service-msm#设置路由断⾔,代理servicerId为auth-service的/auth/路径[3].predicates= Path=/*/msm/**三、封装注册短信验证码接⼝1、添加配置类@Componentpublic class ConstantPropertiesUtils implements InitializingBean { @Value("${Id}") private String regionId; @Value("${KeyId}") private String accessKeyId; @Value("${}") private String secret; public static String REGION_Id; public static String ACCESS_KEY_ID; public static String SECRECT; @Override public void afterPropertiesSet() throws Exception { REGION_Id=regionId; ACCESS_KEY_ID=accessKeyId; SECRECT=secret; }}2、封装service接⼝和实现类public interface MsmService { //发送⼿机验证码 boolean send(String phone, String code);}@Servicepublic class MsmServiceImpl implements MsmService { @Override public boolean send(String phone, String code) { //判断⼿机号是否为空 if(y(phone)) { return false; } //整合阿⾥云短信服务 //设置相关参数 DefaultProfile profile = DefaultProfile. getProfile(_Id, _KEY_ID, T); IAcsClient client = new DefaultAcsClient(profile); CommonRequest request = new CommonRequest(); //tocol(); hod(); ain(""); sion("2017-05-25"); ion("SendSms"); //⼿机号 ryParameter("PhoneNumbers", phone); //签名名称 ryParameter("SignName", "我的⾕粒在线教育⽹站"); //模板code ryParameter("TemplateCode", "SMS_180051135"); //验证码 使⽤json格式 {"code":"123456"} Map
发布评论