|
|
|
@@ -222,6 +222,22 @@ func timestampOldThan(ts int32, sec int32) bool { |
|
|
|
return diff > sec |
|
|
|
} |
|
|
|
|
|
|
|
func buildSignature(token string) (signature, timestamp, nonce string) { |
|
|
|
timestamp = fmt.Sprintf("%d", int32(time.Now().Unix())) |
|
|
|
nonce = "1461107899" //a randome string cut from previous wechat request |
|
|
|
signature = calculateSignature(timestamp, nonce, token) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
func buildReqCommonSignature(req *http.Request, token string) { |
|
|
|
signature, timestamp, nonce := buildSignature(token) |
|
|
|
q := req.URL.Query() |
|
|
|
q.Add("signature", signature) |
|
|
|
q.Add("timestamp", timestamp) |
|
|
|
q.Add("nonce", nonce) |
|
|
|
req.URL.RawQuery = q.Encode() |
|
|
|
} |
|
|
|
|
|
|
|
// func checkSignature1() bool { |
|
|
|
// s1 := "e39de9f2e28079c01ebb4b803dfc3442b819545c" |
|
|
|
// t1 := "1492970761" |