我在使用小程序初始化wxapi2时,接口显示调用成功,但是数据库里没有保存access_token,是需要自己手动往数据库save一下吗?
controller调用如下:
String openid = map.getString("openid");
WxApi2 wxApi2 = wxService.getWxApi2(wxid);
getWxApi2方法如下:
public synchronized WxApi2 getWxApi2(String wxid) {
WxApi2Impl wxApi2 = Globals.WxMap.getAs(wxid, WxApi2Impl.class);
if (wxApi2 == null) {
Wx_config appInfo = wxConfigService.fetch(Cnd.where("id", "=", wxid));
JedisAgenAccessTokenStore redisAccessTokenStore = new JedisAgenAccessTokenStore("nutzwk:wx:token:" + wxid,jedisAgent);
wxApi2 = new WxApi2Impl();
wxApi2.setAppid(appInfo.getAppid());
wxApi2.setAppsecret(appInfo.getAppsecret());
wxApi2.setEncodingAesKey(appInfo.getEncodingAESKey());
wxApi2.setToken(appInfo.getToken());
wxApi2.setAccessTokenStore(redisAccessTokenStore);
Globals.WxMap.put(wxid, wxApi2);
}
return wxApi2;
}
接口返回记录如下:
{"access_token":"32_eX4ytnUrx8X1m4fDKVJqQFGYEcl-7UjVoyI_ZvdvD_MOn8w_ideHk8voJjTErVz0SAgpRT22quQmRsGX8QK3Co6KehYpvbewTkb-B6ofWFDd9bQEcT71yOx16ILZsTwBdtP36ZM12V8W9IrGGHRdAFABCM","expires_in":7200}