1 Star 0 Fork 0

h79 / gothird

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
aliyun.go 1.35 KB
一键复制 编辑 原始数据 按行查看 历史
huqiuyun 提交于 2023-07-25 18:13 . 整理代码
package notify
import (
"gitee.com/h79/gothird/config"
"gitee.com/h79/goutils/common/result"
"github.com/aliyun/alibaba-cloud-sdk-go/sdk"
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests"
)
// https://help.aliyun.com/document_detail/55491.html?spm=a2c4g.11186623.6.658.2b573144YbPBi1
// https://api.aliyun.com/?spm=a2c4g.11186623.2.13.796556e0tRbdOf#/?product=Dysmsapi&api=SendSms
func SendAliyun(conf *config.SmsConfig, phoneNums string, content string) (string, error) {
client, err := sdk.NewClientWithAccessKey(conf.RegionId, conf.AccessKey, conf.Secret)
if err != nil {
return "", result.Error(result.ErrSmsInternal, err.Error())
}
if phoneNums == "" {
phoneNums = conf.PhoneNums
}
request := requests.NewCommonRequest()
request.Method = "POST"
request.Scheme = "https" // https | http
request.ApiName = "SendSms"
request.Version = "2017-05-25"
request.Domain = conf.Domain
request.QueryParams["RegionId"] = conf.RegionId
request.QueryParams["SignName"] = conf.SignName //短信的签名 签名名称
request.QueryParams["TemplateCode"] = conf.TempCode //模板号
request.QueryParams["PhoneNumbers"] = phoneNums
request.QueryParams["TemplateParam"] = content
res, err := client.ProcessCommonRequest(request)
if err != nil {
return "", result.Error(result.ErrEmailInternal, err.Error())
}
return res.GetHttpContentString(), nil
}
1
https://gitee.com/h79/gothird.git
git@gitee.com:h79/gothird.git
h79
gothird
gothird
v1.8.101

搜索帮助

53164aa7 5694891 3bd8fe86 5694891