|
- package t3
-
- 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"
- "time"
- )
-
- func GetT3Url(key, secret string, param map[string]string) map[string]string {
- jsonStr := comm.GetSortJson(param)
- send, _ := GetSend("/openapi/marketing/union/v1/generate/link", key, secret, param["sourceId"], jsonStr)
- res := map[string]string{
- "link": gjson.Get(send, "data.link").String(),
- "appId": gjson.Get(send, "data.appId").String(),
- "appSource": gjson.Get(send, "data.appSource").String(),
- }
- return res
- }
- func GetT3Order(key, secret string, param map[string]string) []T3Order {
- jsonStr := comm.GetSortJson(param)
- send, _ := GetSend("/openapi/api/v1/marketing/union/activity/order/page", key, secret, param["sourceId"], jsonStr)
- list := make([]T3Order, 0)
- json.Unmarshal([]byte(gjson.Get(send, "data.data").String()), &list)
- return list
- }
- func GetSend(method, key, secret, sourceId, jsonStr string) (string, error) {
- url := "https://exchange.t3go.cn" + method
- now := zhios_third_party_utils.Int64ToStr(time.Now().Unix() * 1000)
- tmp := map[string]string{
- "x-t3-nonce": php2go.Md5(sourceId + now),
- "x-t3-timestamp": now,
- "x-t3-version": "V1",
- "x-t3-key": key,
- "x-t3-signature-method": "MD5",
- }
- signStr := "POST" + method
- headers := make(map[string]string)
- keyList := []string{"x-t3-key", "x-t3-nonce", "x-t3-signature-method", "x-t3-timestamp", "x-t3-version"}
- for _, v := range keyList {
- headers[v] = tmp[v]
- signStr += v + ":" + tmp[v]
- }
- signStr += php2go.Md5(jsonStr) + secret
- headers["x-t3-signature-headers"] = "x-t3-nonce,x-t3-timestamp,x-t3-version,x-t3-key,x-t3-signature-method"
- headers["x-t3-signature"] = php2go.Md5(signStr)
- post, err := zhios_third_party_utils.CurlPost(url, jsonStr, headers)
- fmt.Println(string(post))
- fmt.Println(err)
- return string(post), err
- }
|