我正在使用Twitter4j的TwitterStream
功能来接收一个频繁关注Twitter用户推文的流,如下所示:
...
private void initTwitterStream(AccessToken accessToken) {
twitterStream = new TwitterStreamFactory().getInstance();
twitterStream.setOAuthConsumer(consumerKey, consumerSecret);
twitterStream.setOAuthAccessToken(accessToken);
twitterStream.addListener(createUserStreamListener());
twitterStream.user("realDonaldTrump");
logger.info("Listener initiated; listening for status updates.");
}
private UserStreamListener createUserStreamListener() {
return new UserStreamAdapter() {
public void onStatus(Status status) {
log(status); // logs the tweet author and text
}
};
}
...
我遇到的问题是,我正在从他们的推文中标记此用户的任何人那里获得更新。例如:
16:22:02.150 [Twitter4J Async Dispatcher[0]] INFO c.d.i.twitter.TwitterListenerService - Received status update from [foo1234]: @realDonaldTrump never trust a man's perspective of technology after he uses "cyber" as a noun
如何配置Twitter4j,以便我只接收此用户创作的推文,而不是提及他的推文?