1
twitter4jでツイートを取得しようとしています。私はサンプルコードを試して、それが動作しない理由を見る - 私はStatusListener
を変換することはできません。しかし私は私の問題を解決することはできません。Twitter4j:StatusListenerをtwitter4j.StreamListenerに変換できません
誰かがこれを解決する方法を知っていますか?
import twitter4j.*;
import twitter4j.conf.ConfigurationBuilder;
import java.io.IOException;
public class Home
{
public static void main (String args[]) throws TwitterException, IOException
{
ConfigurationBuilder cf = new ConfigurationBuilder();
cf.setDebugEnabled(true)
.setOAuthConsumerKey("")
.setOAuthConsumerSecret("")
.setOAuthAccessToken("")
.setOAuthAccessTokenSecret("");
StatusListener listener = new StatusListener(){
public void onStatus(Status status) {
System.out.println(status.getUser().getName() + " : " + status.getText());
}
public void onDeletionNotice(StatusDeletionNotice statusDeletionNotice) {}
public void onTrackLimitationNotice(int numberOfLimitedStatuses) {}
public void onException(Exception ex) {
ex.printStackTrace();
}
};
TwitterStream twitterStream = new TwitterStreamFactory().getInstance();
twitterStream.addListener(listener);
twitterStream.sample();
}
}
おかげで、それはそれでした! –