newClient 创建腾讯云短信客户端
()
| 11 | |
| 12 | // newClient 创建腾讯云短信客户端 |
| 13 | func newClient() *tencentsms.Client { |
| 14 | secretId := viper.GetString("sms.tencent.secretId") |
| 15 | secretKey := viper.GetString("sms.tencent.secretKey") |
| 16 | endPoint := viper.GetString("sms.tencent.endPoint") |
| 17 | credential := common.NewCredential( |
| 18 | secretId, |
| 19 | secretKey, |
| 20 | ) |
| 21 | // 创建客户端配置 |
| 22 | cpf := profile.NewClientProfile() |
| 23 | // 设置腾讯云短信服务端点 |
| 24 | cpf.HttpProfile.Endpoint = endPoint |
| 25 | // 创建腾讯云短信客户端 |
| 26 | client, _ := tencentsms.NewClient(credential, regions.Nanjing, cpf) |
| 27 | return client |
| 28 | } |
| 29 | |
| 30 | // InitSms 初始化腾讯云短信实例 |
| 31 | func InitSms() *sms.TencentSms { |