第三方api接口
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.

42 lines
891 B

  1. package dataoke
  2. import (
  3. zhios_third_party_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/utils"
  4. "net/url"
  5. "sort"
  6. "strings"
  7. )
  8. var (
  9. Appkey = "5ce66ae30ff54"
  10. Appsecret = "07350d1665e55e1950a26ebb3dde23ed"
  11. )
  12. // url 地址 params 参数
  13. func SendReq(urls string, params map[string]string) ([]byte, error) {
  14. params["appKey"] = Appkey
  15. params["sign"] = Sign(params, Appsecret)
  16. var s url.URL
  17. q := s.Query()
  18. for k, v := range params {
  19. q.Add(k, v)
  20. }
  21. urls += "?" + q.Encode()
  22. return zhios_third_party_utils.CurlGet(urls, nil)
  23. }
  24. func Sign(args map[string]string, secret string) string {
  25. var keys []string
  26. for k := range args {
  27. keys = append(keys, k)
  28. }
  29. sort.Strings(keys)
  30. var str = ""
  31. for _, k := range keys {
  32. //拼接字符串
  33. str += k + "=" + args[k] + "&"
  34. }
  35. str += "key=" + secret
  36. return strings.ToUpper(zhios_third_party_utils.Md5(str))
  37. }