添加阿里云短信服务支持
This commit is contained in:
30
web/globals/aliyun.go
Normal file
30
web/globals/aliyun.go
Normal file
@@ -0,0 +1,30 @@
|
||||
package globals
|
||||
|
||||
import (
|
||||
"platform/pkg/env"
|
||||
"platform/pkg/u"
|
||||
|
||||
openapi "github.com/alibabacloud-go/darabonba-openapi/v2/client"
|
||||
sms "github.com/alibabacloud-go/dysmsapi-20170525/v4/client"
|
||||
)
|
||||
|
||||
var Aliyun *aliyunClient
|
||||
|
||||
type aliyunClient struct {
|
||||
Sms *sms.Client
|
||||
}
|
||||
|
||||
func InitAliyun() {
|
||||
client, err := sms.NewClient(&openapi.Config{
|
||||
AccessKeyId: &env.AliyunAccessKey,
|
||||
AccessKeySecret: &env.AliyunAccessKeySecret,
|
||||
Endpoint: u.P("dysmsapi.aliyuncs.com"),
|
||||
})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
Aliyun = &aliyunClient{
|
||||
Sms: client,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user