sms_helper.go 1011 B

1234567891011121314151617181920212223242526272829303132333435
  1. package helpers
  2. import (
  3. "fmt"
  4. "github.com/GiterLab/aliyun-sms-go-sdk/dysms"
  5. "github.com/astaxie/beego"
  6. "github.com/tobyzxj/uuid"
  7. "os"
  8. "strings"
  9. )
  10. // 发送发货短信
  11. func DispathSendSms(tels []string, expressNo string) {
  12. if tels == nil || len(tels) == 0 {
  13. return
  14. }
  15. kefuTel := "15876023557"
  16. mobile := strings.Join(tels, ",")
  17. params := fmt.Sprintf(`{"tel":"%s","expressNo":"%s"}`, kefuTel, expressNo)
  18. /* ok, resp := alidayu.SendSMS(mobile, sign, template, params)*/
  19. dysms.HTTPDebugEnable = true
  20. dysms.SetACLClient(beego.AppConfig.String("AliSmsAccessId"), beego.AppConfig.String("AliSmsAccessSecret")) // dysms.New(ACCESSID, ACCESSKEY)
  21. sign := "凤凰菁选"
  22. //sign := "凤凰玖玖"
  23. template := "SMS_201456487"
  24. // 短信发送
  25. respSendSms, err := dysms.SendSms(uuid.New(), mobile, sign, template, params).DoActionWithException()
  26. if err != nil {
  27. fmt.Println("send sms failed", err, respSendSms.Error())
  28. os.Exit(0)
  29. }
  30. fmt.Println("send sms succeed", respSendSms.String())
  31. return
  32. }