public final class TwitterStream extends TwitterOAuthSupportBaseImpl implements java.io.Serializable
Modifier and Type | Class and Description |
---|---|
(package private) class |
TwitterStream.StreamHandlingThread |
Modifier and Type | Field and Description |
---|---|
private TwitterStream.StreamHandlingThread |
handler |
private twitter4j.internal.http.HttpClientWrapper |
http |
private static int |
HTTP_ERROR_INITIAL_WAIT |
private static int |
HTTP_ERROR_WAIT_CAP |
private static twitter4j.internal.logging.Logger |
logger |
private static int |
NO_WAIT |
private static long |
serialVersionUID |
private StatusListener |
statusListener |
private static int |
TCP_ERROR_INITIAL_WAIT |
private static int |
TCP_ERROR_WAIT_CAP |
id, screenName
rateLimitStatusListener
auth, conf
Constructor and Description |
---|
TwitterStream()
Deprecated.
use
TwitterStreamFactory.getInstance() instead. |
TwitterStream(Configuration conf,
Authorization auth,
StatusListener listener) |
TwitterStream(java.lang.String screenName,
java.lang.String password)
Deprecated.
use
TwitterStreamFactory.getInstance() instead. |
TwitterStream(java.lang.String screenName,
java.lang.String password,
StatusListener listener)
Deprecated.
use
TwitterStreamFactory.getInstance() instead. |
Modifier and Type | Method and Description |
---|---|
void |
cleanup() |
void |
filter(FilterQuery query)
Start consuming public statuses that match one or more filter predicates.
|
void |
filter(int count,
int[] follow,
java.lang.String[] track)
Deprecated.
use
filter(FilterQuery) instead |
void |
firehose(int count)
Starts listening on all public statuses.
|
private StatusStream |
getCountStream(java.lang.String relativeUrl,
int count) |
StatusStream |
getFilterStream(FilterQuery query)
Returns public statuses that match one or more filter predicates.
|
StatusStream |
getFilterStream(int count,
int[] follow,
java.lang.String[] track)
Deprecated.
use
getFilterStream(FilterQuery) instead |
StatusStream |
getFirehoseStream(int count)
Returns a status stream of all public statuses.
|
StatusStream |
getLinksStream(int count)
Returns a status stream of all public statuses containing links.
|
StatusStream |
getRetweetStream()
Returns a stream of all retweets.
|
StatusStream |
getSampleStream()
Returns a stream of random sample of all public statuses.
|
UserStream |
getUserStream()
User Stream is currently in beta.
Read through and follow the doc! Do not release products using UserStream during the preview / beta period. |
void |
links(int count)
Starts listening on all public statuses containing links.
|
void |
retweet()
Starts listening on all retweets.
|
void |
sample()
Starts listening on random sample of all public statuses.
|
void |
setStatusListener(StatusListener statusListener) |
void |
setUserStreamListener(UserStreamListener statusListener) |
private void |
startHandler(TwitterStream.StreamHandlingThread handler) |
private void |
startUserStreamHandler(TwitterStream.StreamHandlingThread handler) |
void |
stream(java.lang.String relativeUrl,
int count,
boolean handleUserStream)
Starts listening on a tweet stream.
|
void |
user()
User Stream is currently in beta.
Read through and follow the doc! Do not release products using UserStream during the preview / beta period. |
getOAuthAccessToken, getOAuthAccessToken, getOAuthAccessToken, getOAuthAccessToken, getOAuthAccessToken, getOAuthAccessToken, getOAuthRequestToken, getOAuthRequestToken, isOAuthEnabled, setOAuthAccessToken, setOAuthAccessToken, setOAuthConsumer
equals, hashCode, httpResponseReceived, setRateLimitStatusListener, shutdown
ensureAuthorizationEnabled, ensureBasicEnabled, getAuthorization, isBasicAuthEnabled, toString
private final twitter4j.internal.http.HttpClientWrapper http
private static final twitter4j.internal.logging.Logger logger
private StatusListener statusListener
private TwitterStream.StreamHandlingThread handler
private static final long serialVersionUID
private static final int TCP_ERROR_INITIAL_WAIT
private static final int TCP_ERROR_WAIT_CAP
private static final int HTTP_ERROR_INITIAL_WAIT
private static final int HTTP_ERROR_WAIT_CAP
private static final int NO_WAIT
public TwitterStream()
TwitterStreamFactory.getInstance()
instead.public TwitterStream(java.lang.String screenName, java.lang.String password)
TwitterStreamFactory.getInstance()
instead.screenName
- screen namepassword
- passwordpublic TwitterStream(java.lang.String screenName, java.lang.String password, StatusListener listener)
TwitterStreamFactory.getInstance()
instead.screenName
- screen namepassword
- passwordlistener
- listenerTwitterStream(Configuration conf, Authorization auth, StatusListener listener)
public void firehose(int count)
count
- Indicates the number of previous statuses to stream before transitioning to the live stream.StatusStream
,
Twitter API Wiki / Streaming API Documentation - firehosepublic StatusStream getFirehoseStream(int count) throws TwitterException
count
- Indicates the number of previous statuses to stream before transitioning to the live stream.TwitterException
- when Twitter service or network is unavailableStatusStream
,
Twitter API Wiki / Streaming API Documentation - firehosepublic void links(int count)
count
- Indicates the number of previous statuses to stream before transitioning to the live stream.StatusStream
,
Twitter API Wiki / Streaming API Documentation - linkspublic StatusStream getLinksStream(int count) throws TwitterException
count
- Indicates the number of previous statuses to stream before transitioning to the live stream.TwitterException
- when Twitter service or network is unavailableStatusStream
,
Twitter API Wiki / Streaming API Documentation - linkspublic void stream(java.lang.String relativeUrl, int count, boolean handleUserStream)
relativeUrl
- The relative url of the feed, for example "statuses/firehose.json" for the firehose.count
- Indicates the number of previous statuses to stream before transitioning to the live stream.private StatusStream getCountStream(java.lang.String relativeUrl, int count) throws TwitterException
TwitterException
public void retweet()
StatusStream
,
Twitter API Wiki / Streaming API Documentation - retweetpublic StatusStream getRetweetStream() throws TwitterException
TwitterException
- when Twitter service or network is unavailableStatusStream
,
Twitter API Wiki / Streaming API Documentation - retweetpublic void sample()
StatusStream
,
Twitter API Wiki / Streaming API Documentation - samplepublic StatusStream getSampleStream() throws TwitterException
TwitterException
- when Twitter service or network is unavailableStatusStream
,
Twitter API Wiki / Streaming API Documentation - Samplingpublic void user()
public UserStream getUserStream() throws TwitterException
TwitterException
- when Twitter service or network is unavailablepublic void filter(FilterQuery query) throws TwitterException
query
- Filter queryTwitterException
StatusStream
,
Twitter API Wiki / Streaming API Documentation - filterpublic StatusStream getFilterStream(FilterQuery query) throws TwitterException
query
- Filter queryTwitterException
- when Twitter service or network is unavailableStatusStream
,
Twitter API Wiki / Streaming API Documentation - filterpublic void filter(int count, int[] follow, java.lang.String[] track)
filter(FilterQuery)
insteadcount
- Indicates the number of previous statuses to stream before transitioning to the live stream.follow
- Specifies the users, by ID, to receive public tweets from.track
- Specifies keywords to track.StatusStream
,
Twitter API Wiki / Streaming API Documentation - filterpublic StatusStream getFilterStream(int count, int[] follow, java.lang.String[] track) throws TwitterException
getFilterStream(FilterQuery)
insteadfollow
- Specifies the users, by ID, to receive public tweets from.TwitterException
- when Twitter service or network is unavailableStatusStream
,
Twitter API Wiki / Streaming API Documentation - filterprivate void startHandler(TwitterStream.StreamHandlingThread handler)
private void startUserStreamHandler(TwitterStream.StreamHandlingThread handler)
public void cleanup()
public void setStatusListener(StatusListener statusListener)
public void setUserStreamListener(UserStreamListener statusListener)