package tpdaren 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" "github.com/syyongx/php2go" "github.com/tidwall/gjson" "time" ) /*** appid:nqrsce appSecret:KZOl46YF6zposQUFQbIXyXCm2pR0nX5dhkyVCk1EDXE= 7200s */ func TpdarenToken(appid, appSecret string) string { url := "http://tpdaren.jzjxwh.cn/api/v1/get/token?appid=" + php2go.URLEncode(appid) + "&app_secret=" + php2go.URLEncode(appSecret) get, _ := zhios_third_party_utils.CurlGet(url, map[string]string{}) token := gjson.Get(string(get), "data.token").String() return token } func TpdarenSend(method, token string, param map[string]interface{}) (string, error) { url := "http://tpdaren.jzjxwh.cn/api/v1/" + method header := map[string]string{ "token": token, } param["timestamp"] = time.Now().Unix() param["signature"] = getSign(param) post, err := zhios_third_party_utils.CurlPost(url, zhios_third_party_utils.SerializeStr(param), header) return string(post), err } func getSign(param map[string]interface{}) string { str := "" keys := comm.KsortToStrInterface(param) for _, k := range keys { if str == "" { str += k + "=" + zhios_third_party_utils.AnyToString(param[k]) } else { str += "&" + k + "=" + zhios_third_party_utils.AnyToString(param[k]) } } return php2go.Md5(str) }