短信发送方法
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
1.0 KiB

  1. package sms
  2. import (
  3. "log"
  4. "strings"
  5. // "github.com/json-iterator/go"
  6. )
  7. /**
  8. * 发送联通融合通信短信
  9. * @cpcode 商户编号
  10. * @key accessKey
  11. * @excode 扩展码
  12. * @mobiles 手机号多个用逗号隔开
  13. * @templetId 模板id
  14. * @msg 模板中变量的值如果包含多个参数以半角英文逗号分隔
  15. */
  16. func SendByWo(cpcode, key, excode, mobiles, templetid, msg string) (map[string]interface{}, error) {
  17. sign_str := StringJoin(cpcode, msg, mobiles, excode, templetid, key)
  18. sign := strings.ToLower(Md5Str(sign_str))
  19. url := "http://rcsapi.wo.cn:8000/umcinterface/sendtempletmsg"
  20. data := map[string]string{
  21. "cpcode": cpcode,
  22. "msg": msg,
  23. "mobiles": mobiles,
  24. "excode": excode,
  25. "templetid": templetid,
  26. "sign": sign,
  27. }
  28. reply, err := PostJsonData(url, data)
  29. if err != nil {
  30. return nil, err
  31. }
  32. var reply_data map[string]interface{}
  33. err = json.Unmarshal(reply, &reply_data)
  34. if err != nil {
  35. log.Println(string(reply), err)
  36. return nil, err
  37. }
  38. return reply_data, err
  39. }