protected synchronized void reflushAccessToken() {
String url = String.format("%s/token?grant_type=client_credential&appid=%s&secret=%s", base, appid, appsecret);
if (log.isDebugEnabled())
log.debugf("ATS: reflush access_token send: %s", url);
Response resp = Http.get(url);
if (!resp.isOK())
throw new IllegalArgumentException("reflushAccessToken FAIL , openid=" + openid);
String str = resp.getContent();
if (log.isDebugEnabled())
log.debugf("ATS: reflush access_token done: %s", str);
NutMap re = Json.fromJson(NutMap.class, str);
String token = re.getString("access_token");
int expires = re.getInt("expires_in") - 200;//微信默认超时为7200秒,此处设置稍微短一点
accessTokenStore.save(token, expires, System.currentTimeMillis());
}
添加回复
请先登陆