Message.go 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. package lib
  2. import (
  3. "fmt"
  4. openapi "github.com/alibabacloud-go/darabonba-openapi/client"
  5. dysmsapi20170525 "github.com/alibabacloud-go/dysmsapi-20170525/v2/client"
  6. "github.com/alibabacloud-go/tea/tea"
  7. )
  8. func message_CreateClient(accessKeyId *string, accessKeySecret *string) (_result *dysmsapi20170525.Client, _err error) {
  9. config := &openapi.Config{
  10. // 您的AccessKey ID
  11. AccessKeyId: accessKeyId,
  12. // 您的AccessKey Secret
  13. AccessKeySecret: accessKeySecret,
  14. }
  15. // 访问的域名
  16. config.Endpoint = tea.String("dysmsapi.aliyuncs.com")
  17. _result = &dysmsapi20170525.Client{}
  18. _result, _err = dysmsapi20170525.NewClient(config)
  19. return _result, _err
  20. }
  21. func Message_Sand(PhoneNumbers string, TemplateCode string, TemplateParam string) {
  22. client, _err := message_CreateClient(tea.String("LTAI5tBmBMw5s1nFvZsKXSPi"), tea.String("6L386APuJyCS8wyS726spfiwmKSksi"))
  23. if _err != nil {
  24. //Config.AddSysMessage(PhoneNumbers, TemplateCode, TemplateParam, "CreateClient _err")
  25. return
  26. }
  27. sendSmsRequest := &dysmsapi20170525.SendSmsRequest{
  28. PhoneNumbers: tea.String(PhoneNumbers),
  29. SignName: tea.String("宝智达网络科技"),
  30. TemplateCode: tea.String(TemplateCode),
  31. TemplateParam: tea.String(TemplateParam),
  32. }
  33. // 复制代码运行请自行打印 API 的返回值
  34. _result, _err := client.SendSms(sendSmsRequest)
  35. str := fmt.Sprintf("%s", _result.Body)
  36. println(str)
  37. }
  38. // println(lib.Message_Sand("18777951277","SMS_215350603","{\"code\":\"1111\"}"))