package pdd import ( zhios_third_party_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/utils" "encoding/json" "sort" "strings" "time" ) var ( PDD_HOST = "http://gw-api.pinduoduo.com/api/router" PDD_AK = "43eed45f20d94fbf828744a77a45e3e2" PDD_SK = "6ccdd6614f804ed8b0e23c2721be857da3a04b5b" PDD_CS = "4ee672167e1ee51aa3a9ea864d33629a230a114c" ) func send(args map[string]interface{}, method string) ([]byte, error) { args["timestamp"] = zhios_third_party_utils.Int64ToStr(time.Now().UnixNano() / 1e6) args["data_type"] = "JSON" args["client_id"] = PDD_AK args["type"] = method args["sign"] = sign(args, PDD_CS) bargs, err := json.Marshal(args) if err != nil { return nil, err } return zhios_third_party_utils.CurlPost(PDD_HOST, bargs, nil) } func sign(m map[string]interface{}, sk string) string { // key sort keys := make([]string, 0, len(m)) for k := range m { keys = append(keys, k) } sort.Strings(keys) str := "" for _, k := range keys { switch m[k].(type) { case int: str += k + zhios_third_party_utils.IntToStr(m[k].(int)) case string: str += k + m[k].(string) } } str = sk + str + sk return strings.ToUpper(zhios_third_party_utils.Md5(str)) }