Ver a proveniência

滴滴

master
huangjiajun há 3 meses
ascendente
cometimento
deaef9dbc5
1 ficheiros alterados com 30 adições e 1 eliminações
  1. +30
    -1
      didi/api.go

+ 30
- 1
didi/api.go Ver ficheiro

@@ -41,7 +41,7 @@ func GetDidiPoster(key, secret string, param map[string]interface{}) map[string]
return res
}
func GetDidiOrder(key, secret string, param map[string]interface{}) []DidiOrder {
send, _ := PostSend("/openapi/v1.0/order/list", key, secret, param)
send, _ := GetSendJson("/openapi/v1.0/order/list", key, secret, param)
list := make([]DidiOrder, 0)
json.Unmarshal([]byte(gjson.Get(send, "data.order_list").String()), &list)
return list
@@ -71,6 +71,35 @@ func GetSend(method, key, secret string, param map[string]interface{}) (string,
fmt.Println(err)
return string(post), err
}
func GetSendJson(method, key, secret string, param map[string]interface{}) (string, error) {
paramStr := comm.GetSortJson(param)

urls := "https://union.didi.cn" + method

for k, v := range param {
if strings.Contains(urls, "?") == false {
urls += "?" + k + "=" + zhios_third_party_utils.AnyToString(v)
} else {
urls += "&" + k + "=" + zhios_third_party_utils.AnyToString(v)
}
}
param["Timestamp"] = zhios_third_party_utils.Int64ToStr(time.Now().Unix())
param["App-Key"] = key
param["Sign"] = GetSign(param, secret)
headers := map[string]string{
"Timestamp": zhios_third_party_utils.AnyToString(param["Timestamp"]),
"App-Key": zhios_third_party_utils.AnyToString(param["App-Key"]),
"Sign": zhios_third_party_utils.AnyToString(param["Sign"]),
}
fmt.Println(urls)
fmt.Println(paramStr)

post, err := zhios_third_party_utils.CurlGetBody(urls, paramStr, headers)
fmt.Println(string(post))
fmt.Println(err)
return string(post), err
}

func PostSend(method, key, secret string, param map[string]interface{}) (string, error) {
paramStr := comm.GetSortJson(param)
param["Timestamp"] = time.Now().Unix()


Carregando…
Cancelar
Guardar