我正在使用Twitter4J并尝试不断监控我的Twitter帐户,以便发送给我的推文。每次我收到推文时,我都希望保存他们所说的/推文。但是,我有一些问题。这就是我现在所拥有的:
Twitter twitter = TwitterFactory.getSingleton();
//get last 20 mentions
ResponseList<Status> mentions = twitter.getMentionsTimeline();
long lastTweetId = 0000L;
long oldTweetId = 00000000L;
while (true) {
//get the most recent tweet
for(int i = 0; i < 1; i++) {
lastTweetId = mentions.get(i).getId();
}
for (int i = 0; i < 20; i++) {
if (lastTweetId != oldTweetId) {
System.out.println("recent id is " + lastTweetId + mentions.get(i).getText());
System.out.println(mentions.get(i).getUser().getScreenName() + " is who we need to reply to");
oldTweetId = lastTweetId;
}
}
//wait 5 seconds
try {
Thread.sleep(5000);
} catch (InterruptedException ie) {
//Handle exception
}
}
当我向帐户发送新推文时,它似乎无法提取。 知道我错过了什么吗?