优化
This commit is contained in:
+4
-3
@@ -1,8 +1,8 @@
|
||||
package smsx
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/aliyun/alibaba-cloud-sdk-go/services/dysmsapi"
|
||||
)
|
||||
@@ -21,18 +21,19 @@ func NewSms(endPoint string, accessKeyId string, accessKeySecret string) *sms {
|
||||
}
|
||||
}
|
||||
|
||||
func (s *sms) Send(phone, code, signName, templateCode string) error {
|
||||
func (s *sms) Send(phone, signName, templateCode string, params map[string]interface{}) error {
|
||||
client, err := dysmsapi.NewClientWithAccessKey(s.endPoint, s.accessKeyId, s.accessKeySecret)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
paramBy, _ := json.Marshal(params)
|
||||
|
||||
req := dysmsapi.CreateSendSmsRequest()
|
||||
req.Scheme = "https"
|
||||
req.PhoneNumbers = phone
|
||||
req.SignName = signName
|
||||
req.TemplateCode = templateCode
|
||||
req.TemplateParam = fmt.Sprintf(`{"code":"%s"}`, code)
|
||||
req.TemplateParam = string(paramBy)
|
||||
resp, err := client.SendSms(req)
|
||||
// fmt.Printf("sms send: resp:%+v err:%+v", resp, err)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user