### Home Classes Methods

### In Files

- lib/twitter/streaming/client.rb

### Parent

Twitter::Client

### Methods

- ::new
- #before_request
- #filter
- #firehose
- #sample
- #site
- #user

### Class/Module Index

Quicksearch

- Twitter
- Twitter::Arguments
- Twitter::Base
- Twitter::BasicUser
- Twitter::Client
- Twitter::Configuration
- Twitter::Creatable
- Twitter::Cursor
- Twitter::DirectMessage
- Twitter::Entities
- Twitter::Entity
- Twitter::Entity::Hashtag
- Twitter::Entity::Symbol
- Twitter::Entity::URI
- Twitter::Entity::URL
- Twitter::Entity::UserMention
- Twitter::Enumerable
- Twitter::Error
- Twitter::Error::AlreadyFavorited
- Twitter::Error::AlreadyRetweeted
- Twitter::Error::BadGateway
- Twitter::Error::BadRequest
- Twitter::Error::ClientError
- Twitter::Error::Code
- Twitter::Error::ConfigurationError
- Twitter::Error::DuplicateStatus
- Twitter::Error::Forbidden
- Twitter::Error::GatewayTimeout
- Twitter::Error::InternalServerError
- Twitter::Error::NotAcceptable
- Twitter::Error::NotFound
- Twitter::Error::RequestTimeout
- Twitter::Error::ServerError
- Twitter::Error::ServiceUnavailable
- Twitter::Error::TooManyRequests
- Twitter::Error::UnacceptableIO
- Twitter::Error::Unauthorized
- Twitter::Error::UnprocessableEntity
- Twitter::Factory
- Twitter::Geo
- Twitter::Geo::Point
- Twitter::Geo::Polygon
- Twitter::GeoFactory
- Twitter::GeoResults
- Twitter::Identity
- Twitter::Language
- Twitter::List
- Twitter::Media
- Twitter::Media::Photo
- Twitter::MediaFactory
- Twitter::Metadata
- Twitter::OEmbed
- Twitter::Place
- Twitter::Profile
- Twitter::ProfileBanner
- Twitter::REST
- Twitter::REST::API
- Twitter::REST::Client
- Twitter::REST::DirectMessages
- Twitter::REST::Favorites
- Twitter::REST::FriendsAndFollowers
- Twitter::REST::Help
- Twitter::REST::Lists
- Twitter::REST::Media
- Twitter::REST::OAuth
- Twitter::REST::PlacesAndGeo
- Twitter::REST::Request
- Twitter::REST::Request::MultipartWithFile
- Twitter::REST::Response
- Twitter::REST::Response::ParseErrorJson
- Twitter::REST::Response::ParseJson
- Twitter::REST::Response::RaiseError
- Twitter::REST::SavedSearches
- Twitter::REST::Search
- Twitter::REST::SpamReporting
- Twitter::REST::SuggestedUsers
- Twitter::REST::Timelines
- Twitter::REST::Trends
- Twitter::REST::Tweets
- Twitter::REST::Undocumented
- Twitter::REST::Users
- Twitter::REST::Utils
- Twitter::RateLimit
- Twitter::Relationship
- Twitter::Request
- Twitter::SavedSearch
- Twitter::SearchResults
- Twitter::Settings
- Twitter::Size
- Twitter::SourceUser
- Twitter::Streaming
- Twitter::Streaming::Client
- Twitter::Streaming::Connection
- Twitter::Streaming::DeletedTweet
- Twitter::Streaming::Event
- Twitter::Streaming::FriendList
- Twitter::Streaming::MessageParser
- Twitter::Streaming::Response
- Twitter::Streaming::StallWarning
- Twitter::Suggestion
- Twitter::TargetUser
- Twitter::Token
- Twitter::Trend
- Twitter::TrendResults
- Twitter::Tweet
- Twitter::User
- Twitter::Utils
- Twitter::Utils::ClassMethods
- Twitter::Version

No matching classes.

# Twitter::Streaming::Client

### Attributes

connection[W]
ssl_socket_class[RW]
tcp_socket_class[RW]

### Public Class Methods

new(options = {}) click to toggle source

Initializes a new Client object

@param options [Hash] A customizable set of options. @option options [String] :tcp_socket_class A class that Connection will use to create a new TCP socket. @option options [String] :ssl_socket_class A class that Connection will use to create a new SSL socket. @return [Twitter::Streaming::Client]

    # File lib/twitter/streaming/client.rb, line 20
    def initialize(options = {})
      super
      @connection = Streaming::Connection.new(options)
    end

### Public Instance Methods

before_request(&block) click to toggle source

Set a Proc to be run when connection established.

    # File lib/twitter/streaming/client.rb, line 94
    def before_request(&block)
      if block_given?
        @before_request = block
        self
      elsif instance_variable_defined?(:@before_request)
        @before_request
      else
        proc {}
      end
    end

filter(options = {}, &block) click to toggle source

Returns public statuses that match one or more filter predicates

@see dev.twitter.com/docs/api/1.1/post/statuses/filter @see dev.twitter.com/docs/streaming-apis/parameters @note At least one predicate parameter (follow, locations, or track) must be specified. @param options [Hash] A customizable set of options. @option options [String] :follow A comma separated list of user IDs, indicating the users to return statuses for in the stream. @option options [String] :track Includes additional Tweets matching the specified keywords. Phrases of keywords are specified by a comma-separated list. @option options [String] :locations Includes additional Tweets falling within the specified bounding boxes. @yield [Twitter::Tweet, Twitter::Streaming::Event, Twitter::DirectMessage, Twitter::Streaming::FriendList, Twitter::Streaming::DeletedTweet, Twitter::Streaming::StallWarning] A stream of Twitter objects.

    # File lib/twitter/streaming/client.rb, line 35
    def filter(options = {}, &block)
      request(:post, 'https://stream.twitter.com:443/1.1/statuses/filter.json', options, &block)
    end

firehose(options = {}, &block) click to toggle source

Returns all public statuses

@see dev.twitter.com/docs/api/1.1/get/statuses/firehose @see dev.twitter.com/docs/streaming-apis/parameters @note This endpoint requires special permission to access. @param options [Hash] A customizable set of options. @option options [Integer] :count The number of messages to backfill. @yield [Twitter::Tweet, Twitter::Streaming::Event, Twitter::DirectMessage, Twitter::Streaming::FriendList, Twitter::Streaming::DeletedTweet, Twitter::Streaming::StallWarning] A stream of Twitter objects.

    # File lib/twitter/streaming/client.rb, line 47
    def firehose(options = {}, &block)
      request(:get, 'https://stream.twitter.com:443/1.1/statuses/firehose.json', options, &block)
    end

sample(options = {}, &block) click to toggle source

Returns a small random sample of all public statuses

@see dev.twitter.com/docs/api/1.1/get/statuses/sample @see dev.twitter.com/docs/streaming-apis/parameters @yield [Twitter::Tweet, Twitter::Streaming::Event, Twitter::DirectMessage, Twitter::Streaming::FriendList, Twitter::Streaming::DeletedTweet, Twitter::Streaming::StallWarning] A stream of Twitter objects.

    # File lib/twitter/streaming/client.rb, line 56
    def sample(options = {}, &block)
      request(:get, 'https://stream.twitter.com:443/1.1/statuses/sample.json', options, &block)
    end

site(*args, &block) click to toggle source

Streams messages for a set of user

@see dev.twitter.com/docs/api/1.1/get/site @see dev.twitter.com/docs/streaming-apis/streams/site @see dev.twitter.com/docs/streaming-apis/parameters @note Site Streams is currently in a limited beta. Access is restricted to whitelisted accounts. @param follow [Enumerable<Integer, String, Twitter::User>] A list of user IDs, indicating the users to return statuses for in the stream. @param options [Hash] A customizable set of options. @option options [String] :with Specifies whether to return information for just the users specified in the follow parameter, or include messages from accounts they follow. @option options [String] :replies Specifies whether stall warnings should be delivered. @yield [Twitter::Tweet, Twitter::Streaming::Event, Twitter::DirectMessage, Twitter::Streaming::FriendList, Twitter::Streaming::DeletedTweet, Twitter::Streaming::StallWarning] A stream of Twitter objects.

    # File lib/twitter/streaming/client.rb, line 71
    def site(*args, &block)
      arguments = Arguments.new(args)
      user_ids = collect_user_ids(arguments)
      request(:get, 'https://sitestream.twitter.com:443/1.1/site.json', arguments.options.merge(:follow => user_ids.join(',')), &block)
    end

user(options = {}, &block) click to toggle source

Streams messages for a single user

@see dev.twitter.com/docs/api/1.1/get/user @see dev.twitter.com/docs/streaming-apis/streams/user @see dev.twitter.com/docs/streaming-apis/parameters @param options [Hash] A customizable set of options. @option options [String] :with Specifies whether to return information for just the users specified in the follow parameter, or include messages from accounts they follow. @option options [String] :replies Specifies whether to return additional @replies. @option options [String] :stall_warnings Specifies whether stall warnings should be delivered. @option options [String] :track Includes additional Tweets matching the specified keywords. Phrases of keywords are specified by a comma-separated list. @option options [String] :locations Includes additional Tweets falling within the specified bounding boxes. @yield [Twitter::Tweet, Twitter::Streaming::Event, Twitter::DirectMessage, Twitter::Streaming::FriendList, Twitter::Streaming::DeletedTweet, Twitter::Streaming::StallWarning] A stream of Twitter objects.

    # File lib/twitter/streaming/client.rb, line 89
    def user(options = {}, &block)
      request(:get, 'https://userstream.twitter.com:443/1.1/user.json', options, &block)
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.