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

7 months ago
7 months ago
7 months ago
7 months ago
4 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package kdq
  2. import (
  3. zhios_third_party_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/utils"
  4. "fmt"
  5. "github.com/syyongx/php2go"
  6. "io/ioutil"
  7. "log"
  8. "net/http"
  9. "net/url"
  10. "time"
  11. )
  12. //口袋圈
  13. func KdqSend(appkey, appSecret, method string, params map[string]interface{}) (string, error) {
  14. url := "http://open.xr876.cn/" + method
  15. now := time.Now().Unix()
  16. params["dev_username"] = appkey
  17. params["timestamp"] = zhios_third_party_utils.Int64ToStr(now)
  18. sign := php2go.Md5(appkey + appSecret + zhios_third_party_utils.Int64ToStr(now))
  19. params["sign"] = sign
  20. data, err := zhios_third_party_utils.CurlPost(url, zhios_third_party_utils.SerializeStr(params), nil)
  21. fmt.Println(string(data))
  22. return string(data), err
  23. }
  24. func Post(urls string, param map[string]string) ([]byte, error) {
  25. // 设置表单数据
  26. data := url.Values{}
  27. for k, v := range param {
  28. data.Set(k, v)
  29. }
  30. // 构建请求
  31. resp, err := http.PostForm(urls, data)
  32. if err != nil {
  33. log.Fatal(err)
  34. return nil, err
  35. }
  36. defer resp.Body.Close()
  37. res, err := ioutil.ReadAll(resp.Body)
  38. fmt.Println(string(res))
  39. return res, err
  40. }