Browse Source

滴滴

master
huangjiajun 3 months ago
parent
commit
deaef9dbc5
1 changed files with 30 additions and 1 deletions
  1. +30
    -1
      didi/api.go

+ 30
- 1
didi/api.go View File

@@ -41,7 +41,7 @@ func GetDidiPoster(key, secret string, param map[string]interface{}) map[string]
return res return res
} }
func GetDidiOrder(key, secret string, param map[string]interface{}) []DidiOrder { 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) list := make([]DidiOrder, 0)
json.Unmarshal([]byte(gjson.Get(send, "data.order_list").String()), &list) json.Unmarshal([]byte(gjson.Get(send, "data.order_list").String()), &list)
return list return list
@@ -71,6 +71,35 @@ func GetSend(method, key, secret string, param map[string]interface{}) (string,
fmt.Println(err) fmt.Println(err)
return string(post), 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) { func PostSend(method, key, secret string, param map[string]interface{}) (string, error) {
paramStr := comm.GetSortJson(param) paramStr := comm.GetSortJson(param)
param["Timestamp"] = time.Now().Unix() param["Timestamp"] = time.Now().Unix()


Loading…
Cancel
Save