public class TwitterStream extends AStream
Duplicate messages may be delivered when reconnecting to the Streaming API.
Modifier and Type | Class and Description |
---|---|
static class |
TwitterStream.KMethod |
AStream.IListen, AStream.Outage
Modifier and Type | Field and Description |
---|---|
static int |
MAX_KEYWORD_LENGTH
Maximum character length of a tracked keyword or phrase.
|
static int |
MAX_KEYWORDS
Maximum number of keywords which most of us can track.
|
static int |
MAX_USERS
Maximum users who can be tracked.
|
MAX_BUFFER
Constructor and Description |
---|
TwitterStream(Twitter jtwit) |
Modifier and Type | Method and Description |
---|---|
java.util.List<java.lang.Long> |
getFollowUsers() |
java.util.List<java.lang.String> |
getTrackKeywords() |
void |
setFollowUsers(java.util.List<java.lang.Long> userIds) |
void |
setListenersOnly(boolean listenersOnly)
default: false
If true, json is only sent to listeners, and polling based access
via
AStream.getTweets() will return no results. |
void |
setLocation(java.util.List<double[]> boundingBoxes)
Deprecated.
|
void |
setTrackKeywords(java.util.List<java.lang.String> keywords)
See https://dev.twitter.com/docs/streaming-api/methods#track
|
java.lang.String |
toString() |
addListener, addOutage, clear, close, connect, fillInOutages, finalize, getEvents, getForgotten, getOutages, getSystemEvents, getTweets, isAlive, isConnected, popEvents, popSystemEvents, popTweets, removeListener, setAutoReconnect, setPreviousCount
public static int MAX_KEYWORDS
setTrackKeywords(List)
public static final int MAX_KEYWORD_LENGTH
setTrackKeywords(List)
,
Constant Field Valuespublic static final int MAX_USERS
setFollowUsers(List)
,
Constant Field Valuespublic TwitterStream(Twitter jtwit)
client
- This will have it's timeout set to 90 seconds. So you probably
don't want to reuse the object with the REST api.public java.util.List<java.lang.String> getTrackKeywords()
public void setFollowUsers(java.util.List<java.lang.Long> userIds) throws java.lang.IllegalArgumentException
userIds
- Upto 5,000 userids to followjava.lang.IllegalArgumentException
- if userIds is too bigpublic java.util.List<java.lang.Long> getFollowUsers()
@Deprecated public void setLocation(java.util.List<double[]> boundingBoxes)
boundingBoxes
- Each element consists of longitude/latitude south-west,
north-east.public void setTrackKeywords(java.util.List<java.lang.String> keywords)
Terms are exact-matched, and also exact-matched ignoring punctuation. Each term may be up to 60 characters long.
Exact matching on phrases, that is, keywords with spaces, is not supported. Keywords containing punctuation will only exact match tokens and, other than keywords prefixed by # and @, will tend to never match. Non-space separated languages, such as CJK and Arabic, are currently unsupported as tokenization only occurs on whitespace and punctuation. Other UTF-8 phrases should exact match correctly, but will not substitute similar characters to their least-common-denominator. For all these cases, consider falling back to the Search REST API.
keywords
- The default access level allows up to 400 track keywords
(exceeding this will give an exception -- adjust MAX_KEYWORDS
if you
have special privileges).
You can include phrases, separating words with a space.MAX_KEYWORDS
,
MAX_KEYWORD_LENGTH
public java.lang.String toString()
toString
in class java.lang.Object
public void setListenersOnly(boolean listenersOnly)
AStream.getTweets()
will return no results.AStream.addListener(IListen)