Module: Twitter::REST::Timelines

Includes:
Utils
Included in:
API
Defined in:
lib/twitter/rest/timelines.rb

Overview

Methods for accessing timelines

Constant Summary collapse

DEFAULT_TWEETS_PER_REQUEST =

Default number of tweets per request

20
MAX_TWEETS_PER_REQUEST =

Maximum tweets per request

200

Constants included from Utils

Utils::DEFAULT_CURSOR

Instance Method Summary collapse

Methods included from Utils

flat_pmap, pmap

Instance Method Details

#home_timeline(options = {}) ⇒ Array<Twitter::Tweet>

Note:

This method can only return up to 800 Tweets, including retweets.

Returns the 20 most recent Tweets from the authenticating user’s timeline

Examples:

client.home_timeline

Parameters:

  • options (Hash) (defaults to: {})

    A customizable set of options.

Options Hash (options):

  • :since_id (Integer)

    Returns results with an ID greater than the specified ID.

  • :max_id (Integer)

    Returns results with an ID less than the specified ID.

  • :count (Integer)

    Specifies the number of records to retrieve.

  • :trim_user (Boolean, String, Integer)

    Include only the author’s ID.

  • :exclude_replies (Boolean, String, Integer)

    Exclude replies from results.

  • :include_rts (Boolean, String, Integer)

    Include native retweets.

  • :contributor_details (Boolean, String, Integer)

    Include contributor screen names.

Returns:

Raises:

See Also:



137
138
139
# File 'lib/twitter/rest/timelines.rb', line 137

def home_timeline(options = {})
  perform_get_with_objects("/1.1/statuses/home_timeline.json", options, Tweet)
end

#mentions_timeline(options = {}) ⇒ Array<Twitter::Tweet> Also known as: mentions

Note:

This method can only return up to 800 Tweets.

Returns the 20 most recent mentions for the authenticating user

Examples:

client.mentions_timeline

Parameters:

  • options (Hash) (defaults to: {})

    A customizable set of options.

Options Hash (options):

  • :since_id (Integer)

    Returns results with an ID greater than the specified ID.

  • :max_id (Integer)

    Returns results with an ID less than the specified ID.

  • :count (Integer)

    Specifies the number of records to retrieve.

  • :trim_user (Boolean, String, Integer)

    Include only the author’s ID.

Returns:

Raises:

See Also:



32
33
34
# File 'lib/twitter/rest/timelines.rb', line 32

def mentions_timeline(options = {})
  perform_get_with_objects("/1.1/statuses/mentions_timeline.json", options, Tweet)
end

#retweeted_by_me(options = {}) ⇒ Array<Twitter::Tweet>

Note:

This method can only return up to 3,200 Tweets.

Returns the 20 most recent retweets posted by the authenticating user

Examples:

client.retweeted_by_me

Parameters:

  • options (Hash) (defaults to: {})

    A customizable set of options.

Options Hash (options):

  • :since_id (Integer)

    Returns results with an ID greater than the specified ID.

  • :max_id (Integer)

    Returns results with an ID less than the specified ID.

  • :count (Integer)

    Specifies the number of records to retrieve.

  • :trim_user (Boolean, String, Integer)

    Include only the author’s ID.

  • :exclude_replies (Boolean, String, Integer)

    Exclude replies from results.

  • :contributor_details (Boolean, String, Integer)

    Include contributor screen names.

Returns:

Raises:

See Also:



112
113
114
115
116
# File 'lib/twitter/rest/timelines.rb', line 112

def retweeted_by_me(options = {})
  retweets_from_timeline(options) do |opts|
    user_timeline(opts)
  end
end

#retweeted_by_user(user, options = {}) ⇒ Array<Twitter::Tweet> Also known as: retweeted_by

Note:

This method can only return up to 3,200 Tweets.

Returns the 20 most recent retweets posted by the specified user

Examples:

client.retweeted_by_user('sferik')

Parameters:

  • user (Integer, String, Twitter::User)

    A Twitter user ID, screen name, URI, or object.

  • options (Hash) (defaults to: {})

    A customizable set of options.

Options Hash (options):

  • :since_id (Integer)

    Returns results with an ID greater than the specified ID.

  • :max_id (Integer)

    Returns results with an ID less than the specified ID.

  • :count (Integer)

    Specifies the number of records to retrieve.

  • :trim_user (Boolean, String, Integer)

    Include only the author’s ID.

  • :exclude_replies (Boolean, String, Integer)

    Exclude replies from results.

  • :contributor_details (Boolean, String, Integer)

    Include contributor screen names.

Returns:

Raises:

See Also:



84
85
86
87
88
# File 'lib/twitter/rest/timelines.rb', line 84

def retweeted_by_user(user, options = {})
  retweets_from_timeline(options) do |opts|
    user_timeline(user, opts)
  end
end

#retweeted_to_me(options = {}) ⇒ Array<Twitter::Tweet>

Note:

This method can only return up to 800 Tweets, including retweets.

Returns the 20 most recent retweets posted by followed users

Examples:

client.retweeted_to_me

Parameters:

  • options (Hash) (defaults to: {})

    A customizable set of options.

Options Hash (options):

  • :since_id (Integer)

    Returns results with an ID greater than the specified ID.

  • :max_id (Integer)

    Returns results with an ID less than the specified ID.

  • :count (Integer)

    Specifies the number of records to retrieve.

  • :trim_user (Boolean, String, Integer)

    Include only the author’s ID.

  • :exclude_replies (Boolean, String, Integer)

    Exclude replies from results.

  • :contributor_details (Boolean, String, Integer)

    Include contributor screen names.

Returns:

Raises:

See Also:



159
160
161
162
163
# File 'lib/twitter/rest/timelines.rb', line 159

def retweeted_to_me(options = {})
  retweets_from_timeline(options) do |opts|
    home_timeline(opts)
  end
end

#retweets_of_me(options = {}) ⇒ Array<Twitter::Tweet>

Returns the 20 most recent tweets that have been retweeted by others

Examples:

client.retweets_of_me

Parameters:

  • options (Hash) (defaults to: {})

    A customizable set of options.

Options Hash (options):

  • :count (Integer)

    Specifies the number of records to retrieve.

  • :since_id (Integer)

    Returns results with an ID greater than the specified ID.

  • :max_id (Integer)

    Returns results with an ID less than the specified ID.

  • :trim_user (Boolean, String, Integer)

    Include only the author’s ID.

  • :include_user_entities (Boolean, String, Integer)

    Include user entities.

Returns:

Raises:

See Also:



181
182
183
# File 'lib/twitter/rest/timelines.rb', line 181

def retweets_of_me(options = {})
  perform_get_with_objects("/1.1/statuses/retweets_of_me.json", options, Tweet)
end

#user_timeline(user, options = {}) ⇒ Array<Twitter::Tweet>

Note:

This method can only return up to 3,200 Tweets.

Returns the 20 most recent Tweets posted by the specified user

Examples:

client.user_timeline('sferik')

Parameters:

  • user (Integer, String, Twitter::User)

    A Twitter user ID, screen name, URI, or object.

  • options (Hash) (defaults to: {})

    A customizable set of options.

Options Hash (options):

  • :since_id (Integer)

    Returns results with an ID greater than (that is, more recent than) the specified ID.

  • :max_id (Integer)

    Returns results with an ID less than (that is, older than) or equal to the specified ID.

  • :count (Integer)

    Specifies the number of records to retrieve. Must be less than or equal to 200.

  • :trim_user (Boolean, String, Integer)

    Each tweet returned in a timeline will include a user object with only the author’s numerical ID when set to true, ‘t’ or 1.

  • :exclude_replies (Boolean, String, Integer)

    This parameter will prevent replies from appearing in the returned timeline. Using exclude_replies with the count parameter will mean you will receive up-to count tweets - this is because the count parameter retrieves that many tweets before filtering out retweets and replies.

  • :contributor_details (Boolean, String, Integer)

    Specifies that the contributors element should be enhanced to include the screen_name of the contributor.

  • :include_rts (Boolean, String, Integer)

    Specifies that the timeline should include native retweets in addition to regular tweets. Note: If you’re using the trim_user parameter in conjunction with include_rts, the retweets will no longer contain a full user object.

Returns:

Raises:

See Also:



61
62
63
# File 'lib/twitter/rest/timelines.rb', line 61

def user_timeline(*args)
  objects_from_response_with_user(Tweet, :get, "/1.1/statuses/user_timeline.json", args)
end