Package weibo4j

Examples of weibo4j.Status


  public static void main(String[] args) {
    System.setProperty("weibo4j.oauth.consumerKey", Weibo.CONSUMER_KEY);
      System.setProperty("weibo4j.oauth.consumerSecret", Weibo.CONSUMER_SECRET);
        try {
          Weibo weibo = getWeibo(true,args);
          Status status = weibo.updateStatus("............");
          System.out.println(status.getId() + " : "+ status.getText()+"  "+status.getCreatedAt());
         
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
View Full Code Here


      System.setProperty("weibo4j.oauth.consumerSecret", Weibo.CONSUMER_SECRET);
        try {
          Weibo weibo = getWeibo(true,args);
          List<Status> list = weibo.getUserTimeline("1748033497", new Paging(1).count(4));
          if(list.size() > 0) {
            Status status = weibo.showStatus(list.get(0).getId());
              System.out.println( status.getId() + "  : "+status.getText());
          }
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
View Full Code Here

  public static void main(String[] args) {
    System.setProperty("weibo4j.oauth.consumerKey", Weibo.CONSUMER_KEY);
      System.setProperty("weibo4j.oauth.consumerSecret", Weibo.CONSUMER_SECRET);
        try {
          Weibo weibo = getWeibo(true,args);
          Status status = weibo.updateStatus("撒旦撒旦顶顶顶顶顶顶,,");
          Thread.sleep(1000);
          String sid = status.getId()+"";
          Comment comment = weibo.updateComment("踩踩踩踩踩", sid, null);
          System.out.println(comment.getId() + " : " + comment.getText() + "  " + comment.getCreatedAt());
          Thread.sleep(1000);
          comment = weibo.updateComment("踩踩踩踩踩1", sid, null);
          System.out.println(comment.getId() + " : " + comment.getText() + "  " + comment.getCreatedAt());
View Full Code Here

  List<Status> newUserMessages = sinaWeiboApi.getUserTimeline(lastestCreateWeiboMap != null ? lastestCreateWeiboMap.getSinaWeiboId() : null, null);

  log.info("Sina message --> 同期化件数:" + newUserMessages.size());

  // メッセージ単位で同期化処理を行う
  Status status = null;
  try {
    for (int i = newUserMessages.size() - 1; i >= 0; i--) {
    status = newUserMessages.get(i);
    if (this.weiboMapDao.getBySinaWeiboId(status.getId(), user.getId()) == null) {
      syncSinaUserMessage(user, status, new WeiboMap());
    } else {
      log.info("Sina message --> [" + status.getId() + "] 同期化済みでスキップする。");
    }
    }
  } catch (ApiLimitedException e) {
    e.printStackTrace();
  }
View Full Code Here

    try {
      // 转发微博的处理
      if (status.isRetweet()) {

      String retweetId = null;
      Status retweetedStatus = status.getRetweeted_status();
      log.info("Sina Message --> Retweet [" + retweetedStatus.getId() + "]");

      WeiboMap processedWeibo = this.weiboMapDao.getBySinaWeiboId(retweetedStatus.getId(), userMap.getId());
      if (processedWeibo != null) {
        retweetId = String.valueOf(processedWeibo.getTqqWeiboId());
      } else {

        originalMsg = sinaWeiboApi.getOriginalMsg(retweetedStatus.getText().trim());

        StringBuilder retweetMsg = new StringBuilder();
        retweetMsg.append("Sina@").append(retweetedStatus.getUser().getName()).append("//");
        retweetMsg.append(originalMsg);
       
        // 長調整
        if(retweetMsg.length() > 140){
          String sinaURL = "... " + SinaWeiboApi.getStatusPageURL(retweetedStatus.getUser().getId(), retweetedStatus.getId());
          retweetMsg = retweetMsg.delete((140 - sinaURL.length()), retweetMsg.length());
          retweetMsg.append(sinaURL);
        }
       
        try {
          middleResponse = tqqRobotWeiboApi.sendMessage(originalMsg, retweetMsg.toString(), retweetedStatus.getBmiddle_pic(), null);
        } catch (Exception e) {
          middleResponse = new Response();
          middleResponse.setMsg(e.getMessage());
          log.warning("Retweet --> 例外!!!" + e.getMessage());
        }
        log.info("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~X");
        if (middleResponse != null && middleResponse.isOK()) {
        log.info("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Y");
        log.info("Sina Message --> Retweet Successed!!!");
        // データストアへ保存する

        // 同期化履歴レコードの初期化
        WeiboMap retweetWeiboMap = new WeiboMap();
        retweetWeiboMap.setSinaWeiboId(retweetedStatus.getId());
        retweetWeiboMap.setTqqWeiboId(Long.valueOf(middleResponse.getData().getId()));
        retweetWeiboMap.setUserMapId(null);
        retweetWeiboMap.setSource(WeiboSource.Sina);
        retweetWeiboMap.setStatus(WeiboStatus.SUCCESSED);
        weiboMapDao.save(retweetWeiboMap);
        retweetId = middleResponse.getData().getId();
        }
      }
      log.info("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Q");
      if (retweetId != null) {
        log.info("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Z");
        originalMsg = sinaWeiboApi.getOriginalMsg(status.getText().trim());
        response = tqqWeiboApi.retweetMessage(retweetId, originalMsg, status.getBmiddle_pic(), null);
      } else {
        log.info("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~H");
        response = middleResponse;
        response.setApplicationMsg("Sina Message --> Retweet [" + retweetedStatus.getId() + "] Failed!!!!");
      }

      } else { // 转发微博的处理 - END

      // 普通微博的处理
View Full Code Here

  }

  }

  public Status updateStatus(String message, String pics) {
  Status result = null;
  try {

    if (StringUtils.isBlank(pics)) {
    log.info("DEBUG --> " + message);
    result = this.weibo.updateStatus(message);
View Full Code Here

      return;
    }
    }

    // 同じメッセージをsinaへ発表する
    Status status = null;
    Throwable throwable = null;
    String originalMsg = null;
    try {
    // // 转发微博的处理
    // if (status.isRetweet()) {
    //
    // String retweetId = null;
    // Status retweetedStatus = status.getRetweeted_status();
    // log.info("Sina Message --> Retweet [" + retweetedStatus.getId() +
    // "]");
    //
    // WeiboMap processedWeibo =
    // this.weiboMapDao.getBySinaWeiboId(retweetedStatus.getId());
    // if (processedWeibo != null) {
    // retweetId = String.valueOf(processedWeibo.getTqqWeiboId());
    // } else {
    //
    // originalMsg =
    // sinaWeiboApi.getOriginalMsg(retweetedStatus.getText().trim());
    //
    // StringBuilder retweetMsg = new StringBuilder();
    // retweetMsg.append("Sina@").append(retweetedStatus.getUser().getName()).append("//");
    // retweetMsg.append(originalMsg);
    // // TODO 長さ判定
    // retweetMsg.append("//Sina源:").append(SinaWeiboApi.getStatusPageURL(retweetedStatus.getUser().getId(),
    // retweetedStatus.getId()));
    //
    // Response middleResponse = null;//
    // tqqRobotWeiboApi.sendMessage(retweetMsg.toString(),
    // // retweetedStatus.getOriginal_pic(),
    // // null);
    // if (middleResponse != null && middleResponse.isOK()) {
    // log.info("Sina Message --> Retweet Successed!!!");
    // // データストアへ保存する
    //
    // // 同期化履歴レコードの初期化
    // WeiboMap retweetWeiboMap = new WeiboMap();
    // retweetWeiboMap.setSinaWeiboId(retweetedStatus.getId());
    // retweetWeiboMap.setTqqWeiboId(Long.valueOf(middleResponse.getData().getId()));
    // retweetWeiboMap.setUserMapId(null);
    // retweetWeiboMap.setSource(WeiboSource.Sina);
    // retweetWeiboMap.setStatus(WeiboStatus.SUCCESSED);
    // weiboMapDao.save(retweetWeiboMap);
    // retweetId = middleResponse.getData().getId();
    // }
    // }
    // if (retweetId != null) {
    // originalMsg = sinaWeiboApi.getOriginalMsg(status.getText().trim());
    // response = tqqWeiboApi.retweetMessage(retweetId, originalMsg,
    // status.getOriginal_pic(), null);
    // }
    //
    // } else { // 转发微博的处理 - END
    //

    // 普通微博的处理

    // originalMsg = sinaWeiboApi.getOriginalMsg(status.getText().trim());
    // response = tqqWeiboApi.sendMessage(status.getText().trim(),
    // status.getOriginal_pic(), null);
    // }

    status = sinaWeiboApi.updateStatus(msgData.getOrigtext(), null);

    } catch (Exception e) {
    throwable = e;
    }

    // 処理成功ならば、同期化レコードをデータストアへ保存する
    if (status != null) {

    // 同期成功情報を履歴レコードに反映
    weiboMap.setStatus(WeiboStatus.SUCCESSED);
    weiboMap.setSinaWeiboId(Long.valueOf(status.getId()));

    log.info("Tqq Message --> 同期化成功!!!");
    log.info("Tqq Message --> メッセージID:" + msgData.getId());

    } else {
View Full Code Here

TOP

Related Classes of weibo4j.Status

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.