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

41 lines
1.0 KiB

  1. package jd_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, paramJson, version string) (string, error) {
  10. args := map[string]interface{}{
  11. "method": method,
  12. "app_key": keyArr["app_key"],
  13. "access_token": keyArr["access_token"],
  14. "timestamp": time.Now().Format("2006-01-02 15:04:05"),
  15. "format": "json",
  16. "v": version,
  17. "param_json": paramJson,
  18. "sign_method": "md5",
  19. }
  20. // 获取Key
  21. var keys []string
  22. for k := range args {
  23. keys = append(keys, k)
  24. }
  25. // 排序asc
  26. sort.Strings(keys)
  27. str := ""
  28. for _, v := range keys {
  29. if args[v] == "" {
  30. continue
  31. }
  32. str += v + zhios_third_party_utils.AnyToString(args[v])
  33. }
  34. args["sign"] = strings.ToUpper(php2go.Md5(keyArr["app_secret"] + str + keyArr["app_secret"]))
  35. url := "https://router.jd.com/api"
  36. post, err := zhios_third_party_utils.CurlPost(url, args, nil)
  37. return string(post), err
  38. }