第三方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
1.2 KiB

  1. package qianzhu
  2. import (
  3. "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/comm"
  4. zhios_third_party_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/utils"
  5. "fmt"
  6. "github.com/tidwall/gjson"
  7. "strings"
  8. "time"
  9. )
  10. var apiUrl = "https://live.qianzhu8.com/api/v2/platform/getToken"
  11. var url = "https://m.qianzhu8.com"
  12. func GetUrl(method, key, secret string, param map[string]string) string {
  13. str := ""
  14. param["timestamp"] = zhios_third_party_utils.Int64ToStr(time.Now().Unix())
  15. param["platformId"] = key
  16. strMap := comm.KsortToStr(param)
  17. for _, v := range strMap {
  18. if str == "" {
  19. str += v + "=" + param[v]
  20. } else {
  21. str += "&" + v + "=" + param[v]
  22. }
  23. }
  24. str += secret
  25. param["sign"] = zhios_third_party_utils.Md5(str)
  26. for k, v := range param {
  27. if strings.Contains(apiUrl, "?") == false {
  28. apiUrl += "?" + k + "=" + v
  29. } else {
  30. apiUrl += "&" + k + "=" + v
  31. }
  32. }
  33. get, _ := zhios_third_party_utils.CurlGet(apiUrl, nil)
  34. token := gjson.Get(string(get), "data.accessToken").String()
  35. url += method + "?token=" + token + "&platformId=" + param["platformId"] + "&platformUniqueId=" + param["platformUniqueId"] + "&subPlatformId=" + param["subPlatformId"]
  36. fmt.Println(url)
  37. return url
  38. }