Android开发:发送验证码验证手机号——榛子云短信服务

榛子云短信官网

在这里插入图片描述
在这里插入图片描述
点击注册后进行登录 页面如下图所示很是简洁,也省去了很多复杂的流程

在这里插入图片描述
需要进行充值
在这里插入图片描述
价格相对公道,个人开发测试完全够用

我的应用中有后续开发要用到的AppIdAppSecret
在这里插入图片描述

短信模板中可以根据个人需要进行编辑但是要进行审核
后续开发中需要用到模版的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.
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值