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

36 lines
944 B

  1. package pdd_union
  2. import (
  3. zhios_third_party_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/utils"
  4. "github.com/syyongx/php2go"
  5. "sort"
  6. "strings"
  7. "time"
  8. )
  9. func Send(keyArr map[string]string, method string, param map[string]interface{}) (string, error) {
  10. param["client_id"] = keyArr["app_key"]
  11. param["type"] = method
  12. param["data_type"] = "JSON"
  13. param["timestamp"] = zhios_third_party_utils.Int64ToStr(time.Now().Unix())
  14. // 获取Key
  15. var keys []string
  16. for k := range param {
  17. keys = append(keys, k)
  18. }
  19. // 排序asc
  20. sort.Strings(keys)
  21. str := ""
  22. for _, v := range keys {
  23. if param[v] == "" {
  24. continue
  25. }
  26. str += v + zhios_third_party_utils.AnyToString(param[v])
  27. }
  28. param["sign"] = strings.ToUpper(php2go.Md5(keyArr["app_secret"] + str + keyArr["app_secret"]))
  29. url := "http://gw-api.pinduoduo.com/api/router"
  30. post, err := zhios_third_party_utils.CurlPost(url, param, nil)
  31. return string(post), err
  32. }