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

api.go 1.2 KiB

7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
12345678910111213141516171819202122232425262728293031323334353637383940
  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. zhios_third_party_utils.FilePutContents("pdd", zhios_third_party_utils.SerializeStr(param))
  32. zhios_third_party_utils.FilePutContents("pdd", string(post))
  33. if err != nil {
  34. zhios_third_party_utils.FilePutContents("pdd", err.Error())
  35. }
  36. return string(post), err
  37. }