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

40 rivejä
955 B

  1. package zero_buy
  2. import (
  3. "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/comm"
  4. "github.com/syyongx/php2go"
  5. "strings"
  6. )
  7. func ZeroBuyUrl(appSecret string, param map[string]string) string {
  8. url := "https://h5.hlpay178.cn/#/"
  9. param["deviceID"] = strings.ReplaceAll(param["deviceID"], " ", "")
  10. deviceID, _ := php2go.URLDecode(param["deviceID"])
  11. if deviceID != "" {
  12. param["deviceID"] = deviceID
  13. }
  14. for k, v := range param {
  15. if strings.Contains(url, "?") == false {
  16. url += "?" + k + "=" + php2go.URLEncode(v)
  17. } else {
  18. url += "&" + k + "=" + php2go.URLEncode(v)
  19. }
  20. }
  21. sign := GetSign(appSecret, param)
  22. url += "&sign=" + sign
  23. return url
  24. }
  25. func GetSign(appSecret string, param map[string]string) string {
  26. keys := comm.KsortToStr(param)
  27. str := ""
  28. for _, k := range keys {
  29. if str == "" {
  30. str += k + "=" + param[k]
  31. } else {
  32. str += "|" + k + "=" + param[k]
  33. }
  34. }
  35. str += "|" + appSecret
  36. return php2go.Md5(str)
  37. }