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

49 lines
1.5 KiB

  1. package egoer
  2. import (
  3. zhios_third_party_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/utils"
  4. "encoding/json"
  5. "fmt"
  6. "github.com/syyongx/php2go"
  7. "github.com/tidwall/gjson"
  8. "strings"
  9. )
  10. func GetGoods(key, secret, version string, param map[string]interface{}) []EgoerGoods {
  11. send, err := PostSend("/openapi/kwaimoney/product/queryProductList", key, secret, version, param)
  12. var data = make([]EgoerGoods, 0)
  13. if err != nil {
  14. return data
  15. }
  16. list := gjson.Get(send, "data.data").String()
  17. json.Unmarshal([]byte(list), &data)
  18. return data
  19. }
  20. // https://x.egoer.cn/userhome/wordPage 快手团长商品
  21. // a8a6bbf6afad4ffa885986c5a7a1d0a7
  22. // redu20242672GtFyuLYMwmUqX3
  23. func PostSend(method, key, secret, version string, param map[string]interface{}) (string, error) {
  24. urls := "https://open.redu.com/service" + method
  25. param["appkey"] = key
  26. param["version"] = version
  27. param["appSecret"] = secret
  28. for k, v := range param {
  29. if k == "title" {
  30. v = php2go.URLEncode(zhios_third_party_utils.AnyToString(v))
  31. }
  32. if strings.Contains(urls, "?") == false {
  33. urls += "?" + k + "=" + zhios_third_party_utils.AnyToString(v)
  34. } else {
  35. urls += "&" + k + "=" + zhios_third_party_utils.AnyToString(v)
  36. }
  37. }
  38. fmt.Println(urls)
  39. fmt.Println(zhios_third_party_utils.SerializeStr(param))
  40. post, err := zhios_third_party_utils.CurlPost(urls, zhios_third_party_utils.SerializeStr(param), nil)
  41. fmt.Println(string(post))
  42. fmt.Println(err)
  43. return string(post), err
  44. }