List of usage examples for twitter4j TwitterStream setOAuthAccessToken
void setOAuthAccessToken(AccessToken accessToken);
From source file:twitterstreamsample.NewJFrame.java
private void ClickActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ClickActionPerformed // TODO add your handling code here: String consKey = "Your key"; String consSecret = "Your Secret"; String accToken = "Your token"; String accSecret = "Your secret"; StatusListener listener = new StatusListener() { public void onStatus(Status status) { textArea.append(status.getUser().getName() + ":" + status.getText()); }// www . ja va 2s . c o m public void onDeletionNotice(StatusDeletionNotice statusDeletionNotice) { } public void onTrackLimitationNotice(int numberOfLimitedStatuses) { } public void onException(Exception ex) { ex.printStackTrace(); } @Override public void onScrubGeo(long l, long l1) { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } @Override public void onStallWarning(StallWarning sw) { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } }; TwitterStream twitterStream = new TwitterStreamFactory().getInstance(); twitterStream.setOAuthConsumer(consKey, consSecret); twitterStream.setOAuthAccessToken(new AccessToken(accToken, accSecret)); twitterStream.addListener(listener); twitterStream.sample(); }