|
@@ -0,0 +1,64 @@ |
|
|
|
|
|
package third_tikTok_team_goods |
|
|
|
|
|
|
|
|
|
|
|
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" |
|
|
|
|
|
"encoding/json" |
|
|
|
|
|
"fmt" |
|
|
|
|
|
"github.com/syyongx/php2go" |
|
|
|
|
|
"github.com/tidwall/gjson" |
|
|
|
|
|
"strings" |
|
|
|
|
|
"time" |
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
func GetGoods(id, secret string, param map[string]interface{}) []NovajoGoods { |
|
|
|
|
|
send, _ := Send("/kol/", id, secret, param) |
|
|
|
|
|
data := gjson.Get(send, "response.list").String() |
|
|
|
|
|
var list = make([]NovajoGoods, 0) |
|
|
|
|
|
if gjson.Get(send, "status").Int() != 0 { |
|
|
|
|
|
return list |
|
|
|
|
|
} |
|
|
|
|
|
json.Unmarshal([]byte(data), &list) |
|
|
|
|
|
return list |
|
|
|
|
|
} |
|
|
|
|
|
func GetGoodsDetail(id, secret string, param map[string]interface{}) *NovajoGoods { |
|
|
|
|
|
send, _ := Send("/kol/detail", id, secret, param) |
|
|
|
|
|
data := gjson.Get(send, "response").String() |
|
|
|
|
|
if gjson.Get(send, "status").Int() != 0 { |
|
|
|
|
|
return nil |
|
|
|
|
|
} |
|
|
|
|
|
var list NovajoGoods |
|
|
|
|
|
json.Unmarshal([]byte(data), &list) |
|
|
|
|
|
return &list |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//https://dyb.novajo.cn/open/kol-api |
|
|
|
|
|
func Send(method string, id, secret string, param map[string]interface{}) (string, error) { |
|
|
|
|
|
url := "https://api.novajo.cn/api" + method |
|
|
|
|
|
now := time.Now().Unix() * 1000 |
|
|
|
|
|
keys := comm.KsortToStrInterface(param) |
|
|
|
|
|
str := id |
|
|
|
|
|
for _, k := range keys { |
|
|
|
|
|
str += k + "=" + zhios_third_party_utils.AnyToString(param[k]) |
|
|
|
|
|
} |
|
|
|
|
|
str += zhios_third_party_utils.Int64ToStr(now) |
|
|
|
|
|
sign := php2go.Md5(secret + str + secret) |
|
|
|
|
|
fmt.Println(secret + str + secret) |
|
|
|
|
|
fmt.Println(sign) |
|
|
|
|
|
params := param |
|
|
|
|
|
params["id"] = id |
|
|
|
|
|
params["time"] = now |
|
|
|
|
|
params["sign"] = sign |
|
|
|
|
|
for k, v := range params { |
|
|
|
|
|
if strings.Contains(url, "?") == false { |
|
|
|
|
|
url += "?" + k + "=" + zhios_third_party_utils.AnyToString(v) |
|
|
|
|
|
} else { |
|
|
|
|
|
url += "&" + k + "=" + zhios_third_party_utils.AnyToString(v) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
fmt.Println(url) |
|
|
|
|
|
json, err := zhios_third_party_utils.CurlGet(url, nil) |
|
|
|
|
|
fmt.Println(string(json)) |
|
|
|
|
|
fmt.Println(err) |
|
|
|
|
|
return string(json), err |
|
|
|
|
|
} |