Class StreamClient
Defined in: StreamClient.js.
Constructor Attributes | Constructor Name and Description |
---|---|
StreamClient(consumerKey, consumerSecret, token, tokenSecret)
Creates an instance of StreamClient.
|
Method Attributes | Method Name and Description |
---|---|
Returns whether or not the stream client is currently running.
|
|
start(keywords, locations, users, count)
Creates an asynchronous connection to the Twitter Stream API and begins
listening for public statuses that match one or more filter predicates.
|
|
stop()
Disconnects from the Twitter Streaming API.
|
Class Detail
StreamClient(consumerKey, consumerSecret, token, tokenSecret)
Creates an instance of StreamClient.
- Parameters:
- {String} consumerKey
- OAuth consumer key.
- {String} consumerSecret
- OAuth consumer secret.
- {String} token
- OAuth token.
- {String} tokenSecret
- OAuth token secret.
Method Detail
isRunning()
Returns whether or not the stream client is currently running.
- Returns:
- true if the StreamClient is running; false otherwise.
start(keywords, locations, users, count)
Creates an asynchronous connection to the Twitter Stream API and begins
listening for public statuses that match one or more filter predicates.
Listeners should be attached to the
StreamClient
instance in
order to respond to events:
// Request to remove geolocation information from a status twitterStreamClient.on('deleteLocation', function(data) { console.log(data); }); // Status deletion request twitterStreamClient.on('deleteTweet', function(data) { console.log(data); }); // Connection to the stream has been closed twitterStreamClient.on('end', function() { console.log('Connection closed.'); }); // An error has occurred twitterStreamClient.on('error', function(error) { console.log('Error: ' + error.code ? error.code + ' ' + error.message : error.message); }); // A retweet has been received twitterStreamClient.on('retweet', function(retweet) { console.log(retweet); }); // A tweet has been received twitterStreamClient.on('tweet', function(tweet) { console.log(tweet); });See Twitter Streaming API Concepts for information on the structure of the JSON responses returned from the Twitter Streaming API.
- Parameters:
- {Array} keywords
- A set of keywords to track.
- {Array} locations
- A set of one or more latitude/longitude pairs defining geofences to track.
- {Array} users
- A set of users to track.
- {integer} count
- Number of previous statuses to deliver before transitioning to live stream delivery.
stop()
Disconnects from the Twitter Streaming API.