/** * 我的所有微博 * * @param ac * @param oAuth * @param pBroadcastTime */ public void homeWeiboToDb( SocialUserAccount ac, OAuthV2 oAuth, TimelineParameter pBroadcastTime, boolean sign) { String response = ""; try { response = new StatusesAPI(oAuth.getOauthVersion()).homeTimeline(pBroadcastTime); } catch (Exception e) { e.printStackTrace(); } if (StringTool.judgeBlank(response)) { WeiboHandleResult r = weiboSaveDb(response, ac, DictDef.dictInt("weibo_public_timeline")); if (r.isSuccess() && r.getInfoSize() > 0) { pBroadcastTime.lastid = r.getLastid(); pBroadcastTime.pagetime = r.getPagetime(); if (!sign) { // 保存微博的最后时间 sign = true; SocialUserAccountInfo info = new SocialUserAccountInfo(); info.setKey("weibo_last_time"); // 微博最后更新时间 Date d = new Date(Long.parseLong(r.getPagetime()) * 1000); info.setAccountId(ac.getId()); info.setType(DictDef.dict("user_account_info_type")); // 帐号类型 info.setValue(StringDateUtil.parseString(d, 4)); info.setValueType(DictDef.dictInt("date")); info.setValueDate(d); socialUserAccountInfoService.createSocialUserAccountInfo(info); } homeWeiboToDb(ac, oAuth, pBroadcastTime, sign); } } }
private void addTokenInfos(OAuthV2 oAuth, SocialUserAccount socialUserAccount) { SocialUserAccountInfo info = newAccountInfo(socialUserAccount); info.setKey("accessToken"); info.setValue(oAuth.getAccessToken()); info.setValueType(DictDef.dictInt("string")); socialUserAccountInfoService.createSocialUserAccountInfo(info); String expireIn = oAuth.getExpiresIn(); // 失效时间 Date expiredTime = StringDateUtil.addSecond(new Date(), Integer.parseInt(expireIn)); SocialUserAccountInfo expireInfo = newAccountInfo(socialUserAccount); expireInfo.setKey("expiredTime"); expireInfo.setValue(expireIn); expireInfo.setValueDate(expiredTime); expireInfo.setValueType(DictDef.dictInt("date")); socialUserAccountInfoService.createSocialUserAccountInfo(expireInfo); SocialUserAccountInfo oInfo = newAccountInfo(socialUserAccount); oInfo.setKey("openId"); oInfo.setValue(oAuth.getOpenid()); oInfo.setValueType(DictDef.dictInt("string")); socialUserAccountInfoService.createSocialUserAccountInfo(oInfo); oInfo = newAccountInfo(socialUserAccount); oInfo.setKey("openKey"); oInfo.setValue(oAuth.getOpenkey()); oInfo.setValueType(DictDef.dictInt("string")); socialUserAccountInfoService.createSocialUserAccountInfo(oInfo); // refresh_token oInfo = newAccountInfo(socialUserAccount); oInfo.setKey("refreshToken"); oInfo.setValue(oAuth.getRefreshToken()); oInfo.setValueType(DictDef.dictInt("string")); socialUserAccountInfoService.createSocialUserAccountInfo(oInfo); }