项目实践 | 您所在的位置:网站首页 › 智能手机读短信功能 › 项目实践 |
文章目录
1.阿里云短信服务
1.1.开通阿里云短信服务
1.2.添加签名管理与模板管理
1.3.编写发送短信接口
新建短信微服务
1.4.免费试用产品
2.腾讯云短信服务
2.1.注册微信公众号
2.2.申请签名管理和模板管理
2.3.编写代码
3.第三方短信服务
3.1操作方法
本篇文章主要是讲如何免费白嫖,自己实现手机短信验证码的功能,保证不费一分一毛.
即使你什么也不懂,只要按照我的步骤操作,也一定能够实现,这在外人看来有些神秘莫测的短信手机验证!
1.阿里云短信服务
1.1.开通阿里云短信服务
(1)添加签名管理 选择 国内消息 - 签名管理 - 添加签名 1、在service模块下创建子模块service-msm 4、创建启动类 @SpringBootApplication(exclude = DataSourceAutoConfiguration.class) @ComponentScan("com.atguigu") public class MsmApplication { public static void main(String[] args) { SpringApplication.run(MsmApplication.class,args); } }5、在service-msm的pom中引入依赖 com.alibaba fastjson com.aliyun aliyun-java-sdk-core6、编写controller,根据手机号发送短信 @RestController @RequestMapping("/edumsm/msm") //@CrossOrigin public class MsmController { @Autowired private MsmService msmService; @Autowired private RedisTemplate redisTemplate; //发送短信的方法 @GetMapping("send/{phone}") public R sendMsm(@PathVariable String phone) { //1 从redis获取验证码,如果获取到直接返回 String code = redisTemplate.opsForValue().get(phone); if(!StringUtils.isEmpty(code)) { return R.ok(); } //2 如果redis获取 不到,进行阿里云发送 //生成随机值,传递阿里云进行发送 code = RandomUtil.getFourBitRandom(); Map param = new HashMap(); param.put("code",code); //调用service发送短信的方法 boolean isSend = msmService.send(param,phone); if(isSend) { //发送成功,把发送成功验证码放到redis里面 //设置有效时间 |
今日新闻 |
推荐新闻 |
专题文章 |
CopyRight 2018-2019 实验室设备网 版权所有 |