|
@@ -21,6 +21,7 @@ const (
|
|
|
WxTokenKey = "WxToken_%s"
|
|
|
WxTicketKey = "WxTicket_%s"
|
|
|
RedisCode = "sso"
|
|
|
+ MaxExpSec = 5400
|
|
|
)
|
|
|
|
|
|
var (
|
|
@@ -171,7 +172,7 @@ func createAccessToken(appid string) {
|
|
|
token.Expires = time.Now()
|
|
|
}
|
|
|
}
|
|
|
- if (time.Now().Unix()-*token.Lasttime) > 5400 || time.Since(token.Expires).Seconds() >= 0 {
|
|
|
+ if (time.Now().Unix()-*token.Lasttime) > MaxExpSec || time.Since(token.Expires).Seconds() >= 0 {
|
|
|
AllCountT[appid].allTimes++
|
|
|
AllCountT[appid].dayTimes++
|
|
|
resp, err := http.Get(weixinHost + "/token?grant_type=client_credential&appid=" + appid + "&secret=" + AllWxs[appid].Appsecret)
|
|
@@ -194,7 +195,7 @@ func createAccessToken(appid string) {
|
|
|
"access_token": res.AccessToken,
|
|
|
"expires_in": token.Expires.Unix(),
|
|
|
"last_time": token.Lasttime,
|
|
|
- }, int(res.ExpiresIn))
|
|
|
+ }, MaxExpSec)
|
|
|
log.Println(appid, "获取tocken:", AllCountT[appid].dayTimes, "token", res.AccessToken, "expires_in", res.ExpiresIn, "expires", token.Expires.Unix())
|
|
|
}
|
|
|
}
|