Explorar el Código

更新

master
huangjiajun hace 1 año
padre
commit
15526a787b
Se han modificado 3 ficheros con 160 adiciones y 0 borrados
  1. +60
    -0
      kuaishou/api.go
  2. +97
    -0
      kuaishou/kuaishou.go
  3. +3
    -0
      utils/curl.go

+ 60
- 0
kuaishou/api.go Ver fichero

@@ -0,0 +1,60 @@
package kuaishou

import (
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/comm"
zhios_third_party_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/utils"
"fmt"
"github.com/syyongx/php2go"
"strings"
"time"
)

func SendGet(method string, signSecret string, param map[string]string) (string, error) {
url := "https://openapi.kwaixiaodian.com/" + strings.ReplaceAll(method, ".", "/")
param["signMethod"] = "MD5"
param["method"] = method
param["version"] = "1"
param["timestamp"] = zhios_third_party_utils.Int64ToStr(time.Now().UnixNano() / 1e6)
param["sign"] = GetSign(param, signSecret)
for k, v := range param {
if strings.Contains(url, "?") {
url += "&" + k + "=" + php2go.URLEncode(v)
} else {
url += "?" + k + "=" + php2go.URLEncode(v)
}
}
get, err := zhios_third_party_utils.CurlGet(url, nil)
fmt.Println(string(get))
fmt.Println(err)
return string(get), err
}
func SendPost(method string, signSecret string, param map[string]string) (string, error) {
url := "https://openapi.kwaixiaodian.com/" + strings.ReplaceAll(method, ".", "/")
param["signMethod"] = "MD5"
param["method"] = method
param["sign"] = GetSign(param, signSecret)
for k, v := range param {
if strings.Contains(url, "?") {
url += "&" + k + "=" + php2go.URLEncode(v)
} else {
url += "?" + k + "=" + php2go.URLEncode(v)
}
}
get, err := zhios_third_party_utils.CurlPost(url, param["param"], nil)
fmt.Println(string(get))
fmt.Println(err)
return string(get), err
}
func GetSign(param map[string]string, signSecret string) string {
str := ""
keys := comm.KsortToStr(param)
for _, k := range keys {
if str != "" {
str += "&" + k + "=" + param[k]
} else {
str += k + "=" + param[k]
}
}
str += "&signSecret=" + signSecret
return php2go.Md5(str)
}

+ 97
- 0
kuaishou/kuaishou.go Ver fichero

@@ -0,0 +1,97 @@
package kuaishou

import (
zhios_third_party_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/utils"
"fmt"
"strings"
)

/*
app_id 开发者appKey

grant_type 授权的类型,"code"

code 2.2中获取到的code

app_secret 开发者的appSecret
*/
func GetKuaishouToken(args map[string]string) {
url := "https://openapi.kwaixiaodian.com/oauth2/access_token"
for k, v := range args {
if strings.Contains(url, "?") == false {
url += "?" + k + "=" + v
} else {
url += "&" + k + "=" + v
}
}
get, err := zhios_third_party_utils.CurlGet(url, nil)
fmt.Println(url)
fmt.Println(string(get))
fmt.Println(err)

}

/*

*/
func GetKuaishouRefreshToken(args map[string]string) {
url := "https://openapi.kwaixiaodian.com/oauth2/refresh_token"
get, err := zhios_third_party_utils.CurlPost(url, args, nil)
fmt.Println(url)
fmt.Println(string(get))
fmt.Println(err)
}

//https://open.kwaixiaodian.com/zone/docs/api?name=open.distribution.investment.activity.open.list&version=1
func GetKuishouActivity(signSecret string, param map[string]string) (string, error) {

return SendGet("open.distribution.investment.activity.open.list", signSecret, param)
}

//https://open.kwaixiaodian.com/zone/docs/api?name=open.distribution.investment.activity.open.list&version=1
func GetKuishouGoods(signSecret string, param map[string]string) (string, error) {

return SendGet("open.distribution.investment.activity.open.item.list", signSecret, param)
}

////https://open.kwaixiaodian.com/zone/docs/api?name=open.distribution.second.apply.investment.activity.list&version=1
func GetKuishouMyActivity(signSecret string, param map[string]string) (string, error) {

return SendGet("open.distribution.second.apply.investment.activity.list", signSecret, param)
}

//
////https://open.kwaixiaodian.com/zone/docs/api?name=open.distribution.second.apply.investment.activity.item.list&version=1
func GetKuishouMyGoods(signSecret string, param map[string]string) (string, error) {
return SendGet("open.distribution.second.apply.investment.activity.item.list", signSecret, param)
}

//https://open.kwaixiaodian.com/zone/docs/api?name=open.distribution.cps.leader.order.cursor.list&version=1
func GetKuishouOrder(signSecret string, param map[string]string) (string, error) {
return SendGet("open.distribution.cps.leader.order.cursor.list", signSecret, param)
}

//https://open.kwaixiaodian.com/zone/docs/api?name=open.distribution.cps.leader.order.detail&version=1

//https://open.kwaixiaodian.com/zone/docs/api?name=open.distribution.cps.kwaimoney.selection.item.list&version=1
func GetKuishouCpsGoods(signSecret string, param map[string]string) (string, error) {
return SendGet("open.distribution.cps.kwaimoney.selection.item.list", signSecret, param)
}

func GetKuishouCpsGoodsDetail(signSecret string, param map[string]string) (string, error) {
return SendGet("open.distribution.cps.kwaimoney.selection.item.detail", signSecret, param)
}
func GetKuishouCpsKlGoods(signSecret string, param map[string]string) (string, error) {
return SendPost("open.distribution.cps.kwaimoney.link.parse", signSecret, param)
}
func GetKuishouCpsUrl(signSecret string, param map[string]string) (string, error) {
return SendPost("open.distribution.cps.kwaimoney.link.create", signSecret, param)
}
func GetKuishouCpsPid(signSecret string, param map[string]string) (string, error) {
return SendPost("open.distribution.cps.kwaimoney.pid.create", signSecret, param)
}
func GetKuishouCpsOrder(signSecret string, param map[string]string) (string, error) {
return SendPost("open.distribution.cps.kwaimoney.order.list", signSecret, param)
}

//https://open.kwaixiaodian.com/zone/docs/api?name=open.distribution.selection.pick&version=1 橱窗

+ 3
- 0
utils/curl.go Ver fichero

@@ -19,6 +19,9 @@ var CurlDebug bool
func CurlGet(router string, header map[string]string) ([]byte, error) {
return curl(http.MethodGet, router, nil, header)
}
func CurlGetBody(router string, body interface{}, header map[string]string) ([]byte, error) {
return curl(http.MethodGet, router, body, header)
}
func CurlGetJson(router string, body interface{}, header map[string]string) ([]byte, error) {
return curl_new(http.MethodGet, router, body, header)
}


Cargando…
Cancelar
Guardar