短信发送方法
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.

56 lines
1.0 KiB

2 months ago
  1. package sms
  2. import (
  3. "log"
  4. "git.tetele.net/tgo/helper"
  5. )
  6. /*
  7. *
  8. - 百世云发送短信
  9. *
  10. - @param string $sp_id sp_id
  11. - @param string $password 密码
  12. - @param string $mobile 手机号码
  13. - @param string $content 短信内容
  14. - @param string $sms_sign 短信签名
  15. - @return success bool, reply map[string]string, err error
  16. */
  17. func SendByBaishiy(sp_id, password, mobile, sms_sign, content string) (bool, map[string]interface{}, error) {
  18. url := "http://124.220.34.130:9511/api/send-sms-single"
  19. //创蓝接口参数
  20. data := map[string]string{
  21. "sp_id": sp_id,
  22. "password": password,
  23. "content": StringJoin("【", sms_sign, "】", content),
  24. "mobile": mobile,
  25. }
  26. response, err := SendHttp("POST", url, data)
  27. if err != nil {
  28. return false, nil, err
  29. }
  30. var reply map[string]interface{}
  31. err = json.Unmarshal(response, &reply)
  32. if err != nil {
  33. log.Println(string(response), err)
  34. return false, nil, err
  35. }
  36. if helper.ToStr(reply["code"]) != "0" {
  37. return false, reply, nil
  38. }
  39. return true, reply, err
  40. }