Exemplo n.º 1
0
 /**
  * 我的所有微博
  *
  * @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);
     }
   }
 }
Exemplo n.º 2
0
  /**
   * 把微博保存到数据库
   *
   * @param ac
   * @param weiType
   * @return
   */
  @Override
  public int weiboToDb(SocialUserAccount ac) {
    String ownerUserId = ac.getOwnUser();
    int updateSize = 0;
    if (ac != null) {
      String accountId = ac.getId();
      OAuthV2 oAuth = queryAccountToken(accountId);

      // 我的微博
      String webFetchTime = queryMyWeiboTime(ac);
      TimelineParameter pBroadcastTime = new TimelineParameter(oAuth);
      pBroadcastTime.pagetime = webFetchTime;
      // pBroadcastTime.reqnum = "2";
      myWeiboToDb(ac, oAuth, pBroadcastTime);

      // @我的微博
      TimelineParameter pBroadcastTime2 = new TimelineParameter(oAuth);
      String webFetchTime2 = queryMentionWeiboTime(ac);
      pBroadcastTime2.pagetime = webFetchTime2;
      mentionsWeiboToDb(ac, oAuth, pBroadcastTime2);

      // 我关注的所有人的微博
      TimelineParameter pBroadcastTime3 = new TimelineParameter(oAuth);
      String webFetchTime3 = queryHomeWeiboTime(ac);
      pBroadcastTime3.pagetime = webFetchTime3;
      homeWeiboToDb(ac, oAuth, pBroadcastTime3, false);
    }
    return updateSize;
  }
Exemplo n.º 3
0
 public SocialUserAccountInfo newAccountInfo(SocialUserAccount socialUserAccount) {
   SocialUserAccountInfo info = new SocialUserAccountInfo();
   info.setType(DictDef.dict("tencent"));
   info.setValueType(DictDef.dictInt("string"));
   info.setAccountId(socialUserAccount.getId());
   return info;
 }
Exemplo n.º 4
0
 public void updateSocialUserInfo(JSONObject userInfo, SocialUserAccount socialUserAccount) {
   SocialUserAccountInfo info = new SocialUserAccountInfo();
   info.setType(DictDef.dict("tencent"));
   info.setValue(userInfo.getString("fansnum"));
   info.setKey(DictDef.dict("followersCount"));
   info.setValueType(DictDef.dictInt("int"));
   info.setAccountId(socialUserAccount.getId());
   socialUserAccountInfoService.createSocialUserAccountInfo(info);
 }
 /**
  * 设置用户帐号信息
  *
  * @param socialUserAccount
  * @param key
  * @param value
  */
 public void setSocialUserAccountInfo(
     SocialUserAccount socialUserAccount, String key, String value) {
   SocialUserAccountInfo info = new SocialUserAccountInfo();
   info.setKey(key); //
   info.setAccountId(socialUserAccount.getId());
   info.setType(DictDef.dict("user_account_info_type")); // 帐号类型
   info.setValue(value);
   info.setValueString(value);
   info.setValueType(DictDef.dictInt("string"));
   createSocialUserAccountInfo(info);
 }
Exemplo n.º 6
0
 @Override
 public void sendWeibo(SocialUserAccount socialUserAccount, String text, String type) {
   String accountId = socialUserAccount.getId();
   OAuthV2 oAuth = queryAccountToken(accountId);
   int ret = 0;
   TAPI tAPI = new TAPI(oAuth.getOauthVersion()); // 根据oAuth配置对应的连接管理器
   try {
     String response = tAPI.add(new AddParameter(oAuth, text));
     ret = 1;
   } catch (Exception e) {
     e.printStackTrace();
   }
   if (ret == 1) {
     saveSendWeiboRecord(socialUserAccount, text, type);
   }
 }
Exemplo n.º 7
0
 private void initWeiboCommentByAccount(
     SocialUserWeiboComment socialUserWeiboComment, SocialUserAccount ac) {
   socialUserWeiboComment.setUserAccountId(ac.getId());
   socialUserWeiboComment.setOwner(ac.getOwnUser());
   socialUserWeiboComment.setType(ac.getType());
 }