|
@@ -10,14 +10,16 @@ import ( |
|
|
|
|
|
|
|
|
func Send(keyArr map[string]string, method, paramJson, version string) (string, error) { |
|
|
func Send(keyArr map[string]string, method, paramJson, version string) (string, error) { |
|
|
args := map[string]interface{}{ |
|
|
args := map[string]interface{}{ |
|
|
"method": method, |
|
|
|
|
|
"app_key": keyArr["app_key"], |
|
|
|
|
|
"access_token": keyArr["access_token"], |
|
|
|
|
|
"timestamp": time.Now().Format("2006-01-02 15:04:05"), |
|
|
|
|
|
"format": "json", |
|
|
|
|
|
"v": version, |
|
|
|
|
|
"param_json": paramJson, |
|
|
|
|
|
"sign_method": "md5", |
|
|
|
|
|
|
|
|
"method": method, |
|
|
|
|
|
"app_key": keyArr["app_key"], |
|
|
|
|
|
"timestamp": time.Now().Format("2006-01-02 15:04:05"), |
|
|
|
|
|
"format": "json", |
|
|
|
|
|
"v": version, |
|
|
|
|
|
"param_json": paramJson, |
|
|
|
|
|
"sign_method": "md5", |
|
|
|
|
|
} |
|
|
|
|
|
if keyArr["access_token"] != "" { |
|
|
|
|
|
args["access_token"] = keyArr["access_token"] |
|
|
} |
|
|
} |
|
|
// 获取Key |
|
|
// 获取Key |
|
|
var keys []string |
|
|
var keys []string |
|
@@ -34,7 +36,46 @@ func Send(keyArr map[string]string, method, paramJson, version string) (string, |
|
|
str += v + zhios_third_party_utils.AnyToString(args[v]) |
|
|
str += v + zhios_third_party_utils.AnyToString(args[v]) |
|
|
} |
|
|
} |
|
|
args["sign"] = strings.ToUpper(php2go.Md5(keyArr["app_secret"] + str + keyArr["app_secret"])) |
|
|
args["sign"] = strings.ToUpper(php2go.Md5(keyArr["app_secret"] + str + keyArr["app_secret"])) |
|
|
url := "https://router.jd.com/api" |
|
|
|
|
|
|
|
|
url := "https://api.jd.com/routerjson" |
|
|
post, err := zhios_third_party_utils.CurlPost(url, args, nil) |
|
|
post, err := zhios_third_party_utils.CurlPost(url, args, nil) |
|
|
return string(post), err |
|
|
return string(post), err |
|
|
} |
|
|
} |
|
|
|
|
|
func SendGet(keyArr map[string]string, method, paramJson, version string) (string, error) { |
|
|
|
|
|
args := map[string]interface{}{ |
|
|
|
|
|
"method": method, |
|
|
|
|
|
"app_key": keyArr["app_key"], |
|
|
|
|
|
"timestamp": time.Now().Format("2006-01-02 15:04:05"), |
|
|
|
|
|
"format": "json", |
|
|
|
|
|
"v": version, |
|
|
|
|
|
"360buy_param_json": paramJson, |
|
|
|
|
|
"sign_method": "md5", |
|
|
|
|
|
} |
|
|
|
|
|
if keyArr["access_token"] != "" { |
|
|
|
|
|
args["access_token"] = keyArr["access_token"] |
|
|
|
|
|
} |
|
|
|
|
|
// 获取Key |
|
|
|
|
|
var keys []string |
|
|
|
|
|
for k := range args { |
|
|
|
|
|
keys = append(keys, k) |
|
|
|
|
|
} |
|
|
|
|
|
// 排序asc |
|
|
|
|
|
sort.Strings(keys) |
|
|
|
|
|
str := "" |
|
|
|
|
|
for _, v := range keys { |
|
|
|
|
|
if args[v] == "" { |
|
|
|
|
|
continue |
|
|
|
|
|
} |
|
|
|
|
|
str += v + zhios_third_party_utils.AnyToString(args[v]) |
|
|
|
|
|
} |
|
|
|
|
|
args["sign"] = strings.ToUpper(php2go.Md5(keyArr["app_secret"] + str + keyArr["app_secret"])) |
|
|
|
|
|
url := "https://api.jd.com/routerjson" |
|
|
|
|
|
for k, v := range args { |
|
|
|
|
|
if strings.Contains(url, "?") == false { |
|
|
|
|
|
url += "?" + k + "=" + php2go.URLEncode(zhios_third_party_utils.AnyToString(v)) |
|
|
|
|
|
} else { |
|
|
|
|
|
url += "&" + k + "=" + php2go.URLEncode(zhios_third_party_utils.AnyToString(v)) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
post, err := zhios_third_party_utils.CurlGet(url, nil) |
|
|
|
|
|
return string(post), err |
|
|
|
|
|
} |