twitter4j
Class TwitterStream

java.lang.Object
  extended by twitter4j.TwitterStream

public class TwitterStream
extends java.lang.Object

A java reporesentation of the Twitter Streaming API

Since:
Twitter4J 2.0.4
Author:
Yusuke Yamamoto - yusuke at mac.com

Field Summary
protected  HttpClient http
           
protected  java.lang.String source
           
protected  boolean USE_SSL
           
 
Constructor Summary
TwitterStream()
          Constructs a TwitterStream instance.
TwitterStream(java.lang.String userId, java.lang.String password)
           
TwitterStream(java.lang.String userId, java.lang.String password, StatusListener listener)
           
 
Method Summary
 void birddog(int count, int[] follow)
          Deprecated. use filter() instead
 void cleanup()
           
 void filter(int count, int[] follow, java.lang.String[] track)
          See birddog above.
 void firehose(int count)
          Starts listening on all public statuses.
 void follow(int[] follow)
          Deprecated. use filter() instead
 void forceUsePost(boolean forceUsePost)
          Deprecated. some methods don't accept POST method anymore
 void gardenhose()
          Deprecated. use sample() instead
 StatusStream getBirddogStream(int count, int[] follow)
          Deprecated. use filterStream() instead
 java.lang.String getClientURL()
           
 java.lang.String getClientVersion()
           
 StatusStream getFilterStream(int count, int[] follow, java.lang.String[] track)
          Returns stream of public statuses that match one or more filter predicates.
 StatusStream getFirehoseStream(int count)
          Returns a status stream of all public statuses.
 StatusStream getFollowStream(int[] follow)
          Deprecated. use filterStream() instead
 StatusStream getGardenhoseStream()
          Deprecated. use sampleStream() instead
 java.lang.String getPassword()
          Returns authenticating password
 StatusStream getRetweetStream()
          Returns a stream of all retweets.
 StatusStream getSampleStream()
          Returns a stream of random sample of all public statuses.
 StatusStream getShadowStream(int count, int[] follow)
          Deprecated. use filterStream() instead
 java.lang.String getSource()
          Returns the source
 StatusStream getSpritzerStream()
          Deprecated. use sampleStream() instead
 StatusListener getStatusListener()
           
 StatusStream getTrackStream(java.lang.String[] keywords)
          Deprecated. use filterStream() instead
 java.lang.String getUserAgent()
           
 java.lang.String getUserId()
          Returns authenticating userid
 boolean isUsePostForced()
           
 void retweet()
          Starts listening on all retweets.
 void sample()
          Starts listening on random sample of all public statuses.
 void setClientURL(java.lang.String clientURL)
          Sets the X-Twitter-Client-URL header.
 void setClientVersion(java.lang.String version)
          Sets the X-Twitter-Client-Version header.
 void setHttpConnectionTimeout(int connectionTimeout)
          Sets a specified timeout value, in milliseconds, to be used when opening a communications link to the Twitter API.
 void setHttpProxy(java.lang.String proxyHost, int proxyPort)
          Enables use of HTTP proxy
 void setHttpProxyAuth(java.lang.String proxyUser, java.lang.String proxyPass)
          Adds authentication on HTTP proxy
 void setHttpReadTimeout(int readTimeoutMilliSecs)
          Sets the read timeout to a specified timeout, in milliseconds.
 void setPassword(java.lang.String password)
          Sets the password
 void setRequestHeader(java.lang.String name, java.lang.String value)
          Sets the request header name/value combination see Twitter Fan Wiki for detail.
 void setRetryCount(int retryCount)
           
 void setRetryIntervalSecs(int retryIntervalSecs)
           
 void setSource(java.lang.String source)
          Sets X-Twitter-Client http header and the source parameter that will be passed by updating methods.
 void setStatusListener(StatusListener statusListener)
           
 void setUserAgent(java.lang.String userAgent)
          Sets the User-Agent header.
 void setUserId(java.lang.String userId)
          Sets the userid
 void shadow(int count, int[] follow)
          Deprecated. use filter() instead
 void spritzer()
          Deprecated. use sample() instead
 void track(java.lang.String[] keywords)
          Deprecated. use filter() instead
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

http

protected HttpClient http

source

protected java.lang.String source

USE_SSL

protected final boolean USE_SSL
Constructor Detail

TwitterStream

public TwitterStream()
Constructs a TwitterStream instance. UserID and password should be provided by either twitter4j.properties or system property. since Twitter4J 2.0.10


TwitterStream

public TwitterStream(java.lang.String userId,
                     java.lang.String password)

TwitterStream

public TwitterStream(java.lang.String userId,
                     java.lang.String password,
                     StatusListener listener)
Method Detail

firehose

public void firehose(int count)
              throws TwitterException
Starts listening on all public statuses. Available only to approved parties and requires a signed agreement to access. Please do not contact us about access to the firehose. If your service warrants access to it, we'll contact you.

Parameters:
count - Indicates the number of previous statuses to stream before transitioning to the live stream.
Throws:
TwitterException - when Twitter service or network is unavailable
Since:
Twitter4J 2.0.4
See Also:
StatusStream, Twitter API Wiki / Streaming API Documentation - firehose

getFirehoseStream

public StatusStream getFirehoseStream(int count)
                               throws TwitterException
Returns a status stream of all public statuses. Available only to approved parties and requires a signed agreement to access. Please do not contact us about access to the firehose. If your service warrants access to it, we'll contact you.

Parameters:
count - Indicates the number of previous statuses to stream before transitioning to the live stream.
Returns:
StatusStream
Throws:
TwitterException - when Twitter service or network is unavailable
Since:
Twitter4J 2.0.4
See Also:
StatusStream, Twitter API Wiki / Streaming API Documentation - firehose

retweet

public void retweet()
             throws TwitterException
Starts listening on all retweets. The retweet stream is not a generally available resource. Few applications require this level of access. Creative use of a combination of other resources and various access levels can satisfy nearly every application use case. As of 9/11/2009, the site-wide retweet feature has not yet launched, so there are currently few, if any, retweets on this stream.

Throws:
TwitterException - when Twitter service or network is unavailable
Since:
Twitter4J 2.0.10
See Also:
StatusStream, Twitter API Wiki / Streaming API Documentation - retweet

getRetweetStream

public StatusStream getRetweetStream()
                              throws TwitterException
Returns a stream of all retweets. The retweet stream is not a generally available resource. Few applications require this level of access. Creative use of a combination of other resources and various access levels can satisfy nearly every application use case. As of 9/11/2009, the site-wide retweet feature has not yet launched, so there are currently few, if any, retweets on this stream.

Returns:
StatusStream
Throws:
TwitterException - when Twitter service or network is unavailable
Since:
Twitter4J 2.0.10
See Also:
StatusStream, Twitter API Wiki / Streaming API Documentation - firehose

sample

public void sample()
            throws TwitterException
Starts listening on random sample of all public statuses. The default access level provides a small proportion of the Firehose. The "Gardenhose" access level provides a proportion more suitable for data mining and research applications that desire a larger proportion to be statistically significant sample.

Throws:
TwitterException - when Twitter service or network is unavailable
Since:
Twitter4J 2.0.10
See Also:
StatusStream, Twitter API Wiki / Streaming API Documentation - sample

getSampleStream

public StatusStream getSampleStream()
                             throws TwitterException
Returns a stream of random sample of all public statuses. The default access level provides a small proportion of the Firehose. The "Gardenhose" access level provides a proportion more suitable for data mining and research applications that desire a larger proportion to be statistically significant sample.

Returns:
StatusStream
Throws:
TwitterException - when Twitter service or network is unavailable
Since:
Twitter4J 2.0.10
See Also:
StatusStream, Twitter API Wiki / Streaming API Documentation - sample

filter

public void filter(int count,
                   int[] follow,
                   java.lang.String[] track)
            throws TwitterException
See birddog above. Allows following up to 200 users. Publicly available.

Parameters:
count - 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.
Throws:
TwitterException - when Twitter service or network is unavailable
Since:
Twitter4J 2.0.10
See Also:
StatusStream, Twitter API Wiki / Streaming API Documentation - filter

getFilterStream

public StatusStream getFilterStream(int count,
                                    int[] follow,
                                    java.lang.String[] track)
                             throws TwitterException
Returns stream of public statuses that match one or more filter predicates. At least one predicate parameter, track or follow, must be specified. Both parameters may be specified which allows most clients to use a single connection to the Streaming API.

Parameters:
follow - Specifies the users, by ID, to receive public tweets from.
Returns:
StatusStream
Throws:
TwitterException - when Twitter service or network is unavailable
Since:
Twitter4J 2.0.10
See Also:
StatusStream, Twitter API Wiki / Streaming API Documentation - filter

gardenhose

public void gardenhose()
                throws TwitterException
Deprecated. use sample() instead

Starts listening on a percentage of all public statuses, suitable for data mining and research applications that require a statistically significant sample. Available only to approved parties and requires a signed agreement to access.

Throws:
TwitterException - when Twitter service or network is unavailable
Since:
Twitter4J 2.0.4
See Also:
StatusStream, Twitter API Wiki / Streaming API Documentation - gardenhose

getGardenhoseStream

public StatusStream getGardenhoseStream()
                                 throws TwitterException
Deprecated. use sampleStream() instead

Returns a status stream for a percentage of all public statuses, suitable for data mining and research applications that require a statistically significant sample. Available only to approved parties and requires a signed agreement to access.

Returns:
StatusStream
Throws:
TwitterException - when Twitter service or network is unavailable
Since:
Twitter4J 2.0.4
See Also:
StatusStream, Twitter API Wiki / Streaming API Documentation - gardenhose

spritzer

public void spritzer()
              throws TwitterException
Deprecated. use sample() instead

Starts listening on a percentage of all public statuses, suitable for small projects that don't require a statistically significant sample. Publicly available.

Throws:
TwitterException - when Twitter service or network is unavailable
Since:
Twitter4J 2.0.4
See Also:
StatusStream, Twitter API Wiki / Streaming API Documentation - spritizer

getSpritzerStream

public StatusStream getSpritzerStream()
                               throws TwitterException
Deprecated. use sampleStream() instead

Returns a status stream for a percentage of all public statuses, suitable for small projects that don't require a statistically significant sample. Publicly available.

Returns:
StatusStream
Throws:
TwitterException - when Twitter service or network is unavailable
Since:
Twitter4J 2.0.4
See Also:
StatusStream, Twitter API Wiki / Streaming API Documentation - spritizer

birddog

public void birddog(int count,
                    int[] follow)
             throws TwitterException
Deprecated. use filter() instead

Starts listening on public statuses from a specified set of users, by ID. Requires use of the "follow" parameter, documented below. Allows following up to 200,000 users. Available only to approved parties and requires a signed agreement to access.

Parameters:
count - 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.
Throws:
TwitterException - when Twitter service or network is unavailable
Since:
Twitter4J 2.0.4
See Also:
StatusStream, Twitter API Wiki / Streaming API Documentation - birddog

getBirddogStream

public StatusStream getBirddogStream(int count,
                                     int[] follow)
                              throws TwitterException
Deprecated. use filterStream() instead

Returns a status stream for public statuses from a specified set of users, by ID. Requires use of the "follow" parameter, documented below. Allows following up to 200,000 users. Available only to approved parties and requires a signed agreement to access.

Parameters:
count - 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.
Returns:
StatusStream
Throws:
TwitterException - when Twitter service or network is unavailable
Since:
Twitter4J 2.0.4
See Also:
StatusStream, Twitter API Wiki / Streaming API Documentation - birddog

shadow

public void shadow(int count,
                   int[] follow)
            throws TwitterException
Deprecated. use filter() instead

See birddog above. Allows following up to 2,000 users.

Parameters:
count - 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.
Throws:
TwitterException - when Twitter service or network is unavailable
Since:
Twitter4J 2.0.4
See Also:
StatusStream, Twitter API Wiki / Streaming API Documentation - shadow

getShadowStream

public StatusStream getShadowStream(int count,
                                    int[] follow)
                             throws TwitterException
Deprecated. use filterStream() instead

See birddog above. Allows following up to 2,000 users.

Parameters:
count - 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.
Returns:
StatusStream
Throws:
TwitterException - when Twitter service or network is unavailable
Since:
Twitter4J 2.0.4
See Also:
StatusStream, Twitter API Wiki / Streaming API Documentation - shadow

follow

public void follow(int[] follow)
            throws TwitterException
Deprecated. use filter() instead

See birddog above. Allows following up to 200 users. Publicly available.

Parameters:
follow - Specifies the users, by ID, to receive public tweets from.
Throws:
TwitterException - when Twitter service or network is unavailable
Since:
Twitter4J 2.0.4
See Also:
StatusStream, Twitter API Wiki / Streaming API Documentation - follow

getFollowStream

public StatusStream getFollowStream(int[] follow)
                             throws TwitterException
Deprecated. use filterStream() instead

See birddog above. Allows following up to 200 users. Publicly available.

Parameters:
follow - Specifies the users, by ID, to receive public tweets from.
Returns:
StatusStream
Throws:
TwitterException - when Twitter service or network is unavailable
Since:
Twitter4J 2.0.4
See Also:
StatusStream, Twitter API Wiki / Streaming API Documentation - follow

track

public void track(java.lang.String[] keywords)
           throws TwitterException
Deprecated. use filter() instead

Returns public statuses that contain at least one of the specified keywords. Requires use of the "track" parameter, documented below. Allows following up to 20 keywords, subject to Track Limitations, described above. Predicate terms are case-insensitive logical ORs. Terms are exact-matched, and exact-matched ignoring punctuation. Publicly available. Examples: The predicate Twitter will match all public statuses with the following space delimited tokens in their text field: TWITTER, twitter, "Twitter", twitter., #twitter and @twitter. The following tokens will not be matched: TwitterTracker and http://www.twitter.com,

Throws:
TwitterException - when Twitter service or network is unavailable
Since:
Twitter4J 2.0.9
See Also:
StatusStream, Twitter API Wiki / Streaming API Documentation - spritizer

getTrackStream

public StatusStream getTrackStream(java.lang.String[] keywords)
                            throws TwitterException
Deprecated. use filterStream() instead

Throws:
TwitterException
See Also:
getTrackStream(String[])

cleanup

public void cleanup()

getStatusListener

public StatusListener getStatusListener()

setStatusListener

public void setStatusListener(StatusListener statusListener)

setUserAgent

public void setUserAgent(java.lang.String userAgent)
Sets the User-Agent header. System property -Dtwitter4j.http.userAgent overrides this attribute.

Parameters:
userAgent - UserAgent
Since:
Twitter4J 1.1.8

getUserAgent

public java.lang.String getUserAgent()
Returns:
UserAgent
Since:
Twitter4J 1.1.8

setClientVersion

public void setClientVersion(java.lang.String version)
Sets the X-Twitter-Client-Version header. System property -Dtwitter4j.clientVersion overrides this attribute.

Parameters:
version - client version
Since:
Twitter4J 1.1.8

getClientVersion

public java.lang.String getClientVersion()
Returns:
client version
Since:
Twitter4J 1.1.8

setClientURL

public void setClientURL(java.lang.String clientURL)
Sets the X-Twitter-Client-URL header. System property -Dtwitter4j.clientURL overrides this attribute.

Parameters:
clientURL - client URL
Since:
Twitter4J 1.1.8

getClientURL

public java.lang.String getClientURL()
Returns:
client URL
Since:
Twitter4J 1.1.8

setUserId

public void setUserId(java.lang.String userId)
Sets the userid

Parameters:
userId - new userid

getUserId

public java.lang.String getUserId()
Returns authenticating userid

Returns:
userid

setPassword

public void setPassword(java.lang.String password)
Sets the password

Parameters:
password - new password

getPassword

public java.lang.String getPassword()
Returns authenticating password

Returns:
password

setHttpProxy

public void setHttpProxy(java.lang.String proxyHost,
                         int proxyPort)
Enables use of HTTP proxy

Parameters:
proxyHost - proxy host, can be overridden system property -Dtwitter4j.http.proxyHost , -Dhttp.proxyHost
proxyPort - proxy port, can be overridden system property -Dtwitter4j.http.proxyPort , -Dhttp.proxyPort
Since:
Twitter4J 1.1.6

setHttpProxyAuth

public void setHttpProxyAuth(java.lang.String proxyUser,
                             java.lang.String proxyPass)
Adds authentication on HTTP proxy

Parameters:
proxyUser - proxy user, can be overridden system property -Dtwitter4j.http.proxyUser
proxyPass - proxy password, can be overridden system property -Dtwitter4j.http.proxyPassword
Since:
Twitter4J 1.1.6

setHttpConnectionTimeout

public void setHttpConnectionTimeout(int connectionTimeout)
Sets a specified timeout value, in milliseconds, to be used when opening a communications link to the Twitter API. System property -Dtwitter4j.http.connectionTimeout overrides this attribute.

Parameters:
connectionTimeout - an int that specifies the connect timeout value in milliseconds
Since:
Twitter4J 1.1.6

setHttpReadTimeout

public void setHttpReadTimeout(int readTimeoutMilliSecs)
Sets the read timeout to a specified timeout, in milliseconds.

Parameters:
readTimeoutMilliSecs - an int that specifies the timeout value to be used in milliseconds
Since:
Twitter4J 1.1.6

setSource

public void setSource(java.lang.String source)
Sets X-Twitter-Client http header and the source parameter that will be passed by updating methods. System property -Dtwitter4j.source overrides this attribute. System property -Dtwitter4j.source overrides this attribute.

Parameters:
source - the new source
See Also:
How do I get "from [MyApp]" appended to updates sent from my API application?, Twitter - Request a link to your application

getSource

public java.lang.String getSource()
Returns the source

Returns:
source

setRequestHeader

public void setRequestHeader(java.lang.String name,
                             java.lang.String value)
Sets the request header name/value combination see Twitter Fan Wiki for detail. http://twitter.pbwiki.com/API-Docs#RequestHeaders

Parameters:
name - the name of the request header
value - the value of the request header

forceUsePost

public void forceUsePost(boolean forceUsePost)
Deprecated. some methods don't accept POST method anymore

Set true to force using POST method communicating to the server.
This method doesn't take effect anymore

Parameters:
forceUsePost - if true POST method will be used forcibly

isUsePostForced

public boolean isUsePostForced()
Returns:
true if POST is used forcibly

setRetryCount

public void setRetryCount(int retryCount)

setRetryIntervalSecs

public void setRetryIntervalSecs(int retryIntervalSecs)


Copyright © 2009. All Rights Reserved.