//发送短信 阿里SDK调用
client, err := sdk.NewClientWithAccessKey("cn-hangzhou", "LTAIu4sh9mfgqjjr", "sTPSi0Ybj0oFyqDTjQyQNqdq9I9akE")
if err != nil {
beego.Error("电话号码格式错误3")
//2.给容器赋值
resp["errno"] = 3
resp["errmsg"] = "初始化短信错误"
return
} */
//生成6位数随机数
rand.Seed(time.Now().UnixNano())
//阿里云sms短信服务会将开头的0优化掉,导致收到校验码不足6位
//所以首个数字和后面五个分开处理
randNumH := rand.Intn(9) + 1
randNumL := fmt.Sprintf("%05d", rand.Intn(100000))
randNum := strconv.Itoa(randNumH) + randNumL //go字符串拼接
resp["randNum"] = randNum
beego.Info(randNum)
/*
request := requests.NewCommonRequest()
request.Method = "POST"
request.Scheme = "https" // https | http
request.Domain = "dysmsapi.aliyuncs.com"
request.Version = "2017-05-25"
request.ApiName = "SendSms"
request.QueryParams["RegionId"]
阿里云短信服务使用和注意事项
最新推荐文章于 2024-04-16 09:17:08 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)