Module: Twitter::Client::Lists

Included in:
Twitter::Client
Defined in:
lib/twitter/client/lists.rb

Instance Method Summary collapse

Instance Method Details

#list(list, options = {}) ⇒ Twitter::List #list(user, list, options = {}) ⇒ Twitter::List

Note:

Private lists will only be shown if the authenticated user owns the specified list.

Show the specified list

Overloads:

  • #list(list, options = {}) ⇒ Twitter::List

    Returns The specified list.

    Examples:

    Show the authenticated user's "presidents" list

    Twitter.list("presidents")
    Twitter.list(8863586)

    Parameters:

    • list (Integer, String)

      The list_id or slug of the list.

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

      A customizable set of options.

    Returns:

    Raises:

  • #list(user, list, options = {}) ⇒ Twitter::List

    Returns The specified list.

    Examples:

    Show @sferik's "presidents" list

    Twitter.list("sferik", "presidents")
    Twitter.list("sferik", 8863586)
    Twitter.list(7505382, "presidents")
    Twitter.list(7505382, 8863586)

    Parameters:

    • user (Integer, String)

      A Twitter user ID or screen name.

    • list (Integer, String)

      The list_id or slug of the list.

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

      A customizable set of options.

    Returns:

    Raises:

See Also:

Rate Limited?:

  • Yes

Requires Authentication?:

  • Yes



631
632
633
634
635
636
637
638
639
# File 'lib/twitter/client/lists.rb', line 631

def list(*args)
  options = args.last.is_a?(Hash) ? args.pop : {}
  list = args.pop
  options.merge_list!(list)
  owner = args.pop || self.current_user.screen_name
  options.merge_owner!(owner)
  list = get("/1/lists/show.json", options)
  Twitter::List.new(list)
end

#list_add_member(list, user_to_add, options = {}) ⇒ Twitter::List #list_add_member(user, list, user_to_add, options = {}) ⇒ Twitter::List

Note:

Lists are limited to having 500 members.

Add a member to a list

Overloads:

  • #list_add_member(list, user_to_add, options = {}) ⇒ Twitter::List

    Returns The list.

    Examples:

    Add @BarackObama to the authenticated user's "presidents" list

    Twitter.list_add_member("presidents", 813286)
    Twitter.list_add_member(8863586, 813286)

    Parameters:

    • list (Integer, String)

      The list_id or slug of the list.

    • user_to_add (Integer, String)

      The user id or screen name to add to the list.

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

      A customizable set of options.

    Returns:

    Raises:

  • #list_add_member(user, list, user_to_add, options = {}) ⇒ Twitter::List

    Returns The list.

    Examples:

    Add @BarackObama to @sferik's "presidents" list

    Twitter.list_add_member("sferik", "presidents", 813286)
    Twitter.list_add_member('sferik', 8863586, 813286)
    Twitter.list_add_member(7505382, "presidents", 813286)
    Twitter.list_add_member(7505382, 8863586, 813286)

    Parameters:

    • user (Integer, String)

      A Twitter user ID or screen name.

    • list (Integer, String)

      The list_id or slug of the list.

    • user_to_add (Integer, String)

      The user id or screen name to add to the list.

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

      A customizable set of options.

    Returns:

    Raises:

See Also:

Rate Limited?:

  • No

Requires Authentication?:

  • Yes



472
473
474
475
476
477
478
479
480
481
482
# File 'lib/twitter/client/lists.rb', line 472

def list_add_member(*args)
  options = args.last.is_a?(Hash) ? args.pop : {}
  user_to_add = args.pop
  options.merge_user!(user_to_add)
  list = args.pop
  options.merge_list!(list)
  owner = args.pop || self.current_user.screen_name
  options.merge_owner!(owner)
  list = post("/1/lists/members/create.json", options)
  Twitter::List.new(list)
end

#list_add_members(list, users_to_add, options = {}) ⇒ Twitter::List #list_add_members(user, list, users_to_add, options = {}) ⇒ Twitter::List

Note:

Lists are limited to having 500 members, and you are limited to adding up to 100 members to a list at a time with this method.

Adds multiple members to a list

Overloads:

  • #list_add_members(list, users_to_add, options = {}) ⇒ Twitter::List

    Returns The list.

    Examples:

    Add @BarackObama and @pengwynn to the authenticated user's "presidents" list

    Twitter.list_add_members("presidents", [813286, 18755393])
    Twitter.list_add_members('presidents', [813286, 'pengwynn'])
    Twitter.list_add_members(8863586, [813286, 18755393])

    Parameters:

    • list (Integer, String)

      The list_id or slug of the list.

    • users_to_add (Array)

      The user IDs and/or screen names to add.

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

      A customizable set of options.

    Returns:

    Raises:

  • #list_add_members(user, list, users_to_add, options = {}) ⇒ Twitter::List

    Returns The list.

    Examples:

    Add @BarackObama and @pengwynn to @sferik's "presidents" list

    Twitter.list_add_members("sferik", "presidents", [813286, 18755393])
    Twitter.list_add_members('sferik', 'presidents', [813286, 'pengwynn'])
    Twitter.list_add_members('sferik', 8863586, [813286, 18755393])
    Twitter.list_add_members(7505382, "presidents", [813286, 18755393])
    Twitter.list_add_members(7505382, 8863586, [813286, 18755393])

    Parameters:

    • user (Integer, String)

      A Twitter user ID or screen name.

    • list (Integer, String)

      The list_id or slug of the list.

    • users_to_add (Array)

      The user IDs and/or screen names to add.

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

      A customizable set of options.

    Returns:

    Raises:

See Also:

Rate Limited?:

  • No

Requires Authentication?:

  • Yes



356
357
358
359
360
361
362
363
364
365
366
# File 'lib/twitter/client/lists.rb', line 356

def list_add_members(*args)
  options = args.last.is_a?(Hash) ? args.pop : {}
  users_to_add = args.pop
  options.merge_users!(Array(users_to_add))
  list = args.pop
  options.merge_list!(list)
  owner = args.pop || self.current_user.screen_name
  options.merge_owner!(owner)
  list = post("/1/lists/members/create_all.json", options)
  Twitter::List.new(list)
end

#list_create(name, options = {}) ⇒ Twitter::List

Note:

Accounts are limited to 20 lists.

Creates a new list for the authenticated user

Examples:

Create a list named "presidents"

Twitter.list_create("presidents")

Parameters:

  • name (String)

    The name for the list.

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

    A customizable set of options.

Options Hash (options):

  • :mode (String) — default: 'public'

    Whether your list is public or private. Values can be 'public' or 'private'.

  • :description (String)

    The description to give the list.

Returns:

Raises:

See Also:

Rate Limited?:

  • No

Requires Authentication?:

  • Yes



571
572
573
574
# File 'lib/twitter/client/lists.rb', line 571

def list_create(name, options={})
  list = post("/1/lists/create.json", options.merge(:name => name))
  Twitter::List.new(list)
end

#list_destroy(list, options = {}) ⇒ Twitter::List #list_destroy(user, list, options = {}) ⇒ Twitter::List

Note:

Must be owned by the authenticated user.

Deletes the specified list

Overloads:

  • #list_destroy(list, options = {}) ⇒ Twitter::List

    Returns The deleted list.

    Examples:

    Delete the authenticated user's "presidents" list

    Twitter.list_destroy("presidents")
    Twitter.list_destroy(8863586)

    Parameters:

    • list (Integer, String)

      The list_id or slug of the list.

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

      A customizable set of options.

    Returns:

    Raises:

  • #list_destroy(user, list, options = {}) ⇒ Twitter::List

    Returns The deleted list.

    Examples:

    Delete @sferik's "presidents" list

    Twitter.list_destroy("sferik", "presidents")
    Twitter.list_destroy("sferik", 8863586)
    Twitter.list_destroy(7505382, "presidents")
    Twitter.list_destroy(7505382, 8863586)

    Parameters:

    • user (Integer, String)

      A Twitter user ID or screen name.

    • list (Integer, String)

      The list_id or slug of the list.

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

      A customizable set of options.

    Returns:

    Raises:

See Also:

Rate Limited?:

  • No

Requires Authentication?:

  • Yes



509
510
511
512
513
514
515
516
517
# File 'lib/twitter/client/lists.rb', line 509

def list_destroy(*args)
  options = args.last.is_a?(Hash) ? args.pop : {}
  list = args.pop
  options.merge_list!(list)
  owner = args.pop || self.current_user.screen_name
  options.merge_owner!(owner)
  list = delete("/1/lists/destroy.json", options)
  Twitter::List.new(list)
end

#list_member?(list, user_to_check, options = {}) ⇒ Boolean #list_member?(user, list, user_to_check, options = {}) ⇒ Boolean

Check if a user is a member of the specified list

Overloads:

  • #list_member?(list, user_to_check, options = {}) ⇒ Boolean

    Returns true if user is a member of the specified list, otherwise false.

    Examples:

    Check if @BarackObama is a member of the authenticated user's "presidents" list

    Twitter.list_member?("presidents", 813286)
    Twitter.list_member?(8863586, 'BarackObama')

    Parameters:

    • list (Integer, String)

      The list_id or slug of the list.

    • user_to_check (Integer, String)

      The user ID or screen name of the list member.

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

      A customizable set of options.

    Returns:

    • (Boolean)

      true if user is a member of the specified list, otherwise false.

    Raises:

  • #list_member?(user, list, user_to_check, options = {}) ⇒ Boolean

    Returns true if user is a member of the specified list, otherwise false.

    Examples:

    Check if @BarackObama is a member of @sferik's "presidents" list

    Twitter.list_member?("sferik", "presidents", 813286)
    Twitter.list_member?('sferik', 8863586, 'BarackObama')
    Twitter.list_member?(7505382, "presidents", 813286)

    Parameters:

    • user (Integer, String)

      A Twitter user ID or screen name.

    • list (Integer, String)

      The list_id or slug of the list.

    • user_to_check (Integer, String)

      The user ID or screen name of the list member.

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

      A customizable set of options.

    Returns:

    • (Boolean)

      true if user is a member of the specified list, otherwise false.

    Raises:

See Also:

Rate Limited?:

  • Yes

Requires Authentication?:

  • Yes



393
394
395
396
397
398
399
400
401
402
403
404
405
# File 'lib/twitter/client/lists.rb', line 393

def list_member?(*args)
  options = args.last.is_a?(Hash) ? args.pop : {}
  user_to_check = args.pop
  options.merge_user!(user_to_check)
  list = args.pop
  options.merge_list!(list)
  owner = args.pop || self.current_user.screen_name
  options.merge_owner!(owner)
  get("/1/lists/members/show.json", options, :raw => true)
  true
rescue Twitter::Error::NotFound, Twitter::Error::Forbidden
  false
end

#list_members(list, options = {}) ⇒ Twitter::Cursor #list_members(user, list, options = {}) ⇒ Twitter::Cursor

Returns the members of the specified list

Overloads:

  • #list_members(list, options = {}) ⇒ Twitter::Cursor

    Examples:

    Return the members of the authenticated user's "presidents" list

    Twitter.list_members("presidents")
    Twitter.list_members(8863586)

    Parameters:

    • list (Integer, String)

      The list_id or slug of the list.

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

      A customizable set of options.

    Options Hash (options):

    • :cursor (Integer) — default: -1

      Breaks the results into pages. Provide values as returned in the response objects's next_cursor and previous_cursor attributes to page back and forth in the list.

    • :include_entities (Boolean, String, Integer)

      Include Tweet Entities when set to true, 't' or 1.

    Returns:

    Raises:

  • #list_members(user, list, options = {}) ⇒ Twitter::Cursor

    Examples:

    Return the members of @sferik's "presidents" list

    Twitter.list_members("sferik", "presidents")
    Twitter.list_members("sferik", 8863586)
    Twitter.list_members(7505382, "presidents")
    Twitter.list_members(7505382, 8863586)

    Parameters:

    • user (Integer, String)

      A Twitter user ID or screen name.

    • list (Integer, String)

      The list_id or slug of the list.

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

      A customizable set of options.

    Options Hash (options):

    • :cursor (Integer) — default: -1

      Breaks the results into pages. Provide values as returned in the response objects's next_cursor and previous_cursor attributes to page back and forth in the list.

    • :include_entities (Boolean, String, Integer)

      Include Tweet Entities when set to true, 't' or 1.

    Returns:

    Raises:

See Also:

Rate Limited?:

  • Yes

Requires Authentication?:

  • Yes



435
436
437
438
439
440
441
442
443
# File 'lib/twitter/client/lists.rb', line 435

def list_members(*args)
  options = {:cursor => -1}.merge(args.last.is_a?(Hash) ? args.pop : {})
  list = args.pop
  options.merge_list!(list)
  owner = args.pop || self.current_user.screen_name
  options.merge_owner!(owner)
  cursor = get("/1/lists/members.json", options)
  Twitter::Cursor.new(cursor, 'users', Twitter::User)
end

#list_remove_member(list, user_to_remove, options = {}) ⇒ Twitter::List #list_remove_member(user, list, user_to_remove, options = {}) ⇒ Twitter::List

Removes the specified member from the list

Overloads:

  • #list_remove_member(list, user_to_remove, options = {}) ⇒ Twitter::List

    Returns The list.

    Examples:

    Remove @BarackObama from the authenticated user's "presidents" list

    Twitter.list_remove_member("presidents", 813286)
    Twitter.list_remove_member("presidents", 'BarackObama')
    Twitter.list_remove_member(8863586, 'BarackObama')

    Parameters:

    • list (Integer, String)

      The list_id or slug of the list.

    • user_to_remove (Integer, String)

      The user id or screen name of the list member to remove.

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

      A customizable set of options.

    Returns:

    Raises:

  • #list_remove_member(user, list, user_to_remove, options = {}) ⇒ Twitter::List

    Returns The list.

    Examples:

    Remove @BarackObama from @sferik's "presidents" list

    Twitter.list_remove_member("sferik", "presidents", 813286)
    Twitter.list_remove_member("sferik", "presidents", 'BarackObama')
    Twitter.list_remove_member('sferik', 8863586, 'BarackObama')
    Twitter.list_remove_member(7505382, "presidents", 813286)

    Parameters:

    • user (Integer, String)

      A Twitter user ID or screen name.

    • list (Integer, String)

      The list_id or slug of the list.

    • user_to_remove (Integer, String)

      The user id or screen name of the list member to remove.

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

      A customizable set of options.

    Returns:

    Raises:

See Also:

Rate Limited?:

  • No

Requires Authentication?:

  • Yes



110
111
112
113
114
115
116
117
118
119
120
# File 'lib/twitter/client/lists.rb', line 110

def list_remove_member(*args)
  options = args.last.is_a?(Hash) ? args.pop : {}
  user_to_remove = args.pop
  options.merge_user!(user_to_remove)
  list = args.pop
  options.merge_list!(list)
  owner = args.pop || self.current_user.screen_name
  options.merge_owner!(owner)
  list = post("/1/lists/members/destroy.json", options)
  Twitter::List.new(list)
end

#list_subscribe(list, options = {}) ⇒ Twitter::List #list_subscribe(user, list, options = {}) ⇒ Twitter::List

Make the authenticated user follow the specified list

Overloads:

  • #list_subscribe(list, options = {}) ⇒ Twitter::List

    Returns The specified list.

    Examples:

    Subscribe to the authenticated user's "presidents" list

    Twitter.list_subscribe('presidents')
    Twitter.list_subscribe(8863586)

    Parameters:

    • list (Integer, String)

      The list_id or slug of the list.

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

      A customizable set of options.

    Returns:

    Raises:

  • #list_subscribe(user, list, options = {}) ⇒ Twitter::List

    Returns The specified list.

    Examples:

    Subscribe to @sferik's "presidents" list

    Twitter.list_subscribe("sferik", 'presidents')
    Twitter.list_subscribe("sferik", 8863586)
    Twitter.list_subscribe(7505382, 'presidents')

    Parameters:

    • user (Integer, String)

      A Twitter user ID or screen name.

    • list (Integer, String)

      The list_id or slug of the list.

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

      A customizable set of options.

    Returns:

    Raises:

See Also:

Rate Limited?:

  • No

Requires Authentication?:

  • Yes



242
243
244
245
246
247
248
249
250
# File 'lib/twitter/client/lists.rb', line 242

def list_subscribe(*args)
  options = args.last.is_a?(Hash) ? args.pop : {}
  list = args.pop
  options.merge_list!(list)
  owner = args.pop || self.current_user.screen_name
  options.merge_owner!(owner)
  list = post("/1/lists/subscribers/create.json", options)
  Twitter::List.new(list)
end

#list_subscriber?(list, user_to_check, options = {}) ⇒ Boolean #list_subscriber?(user, list, user_to_check, options = {}) ⇒ Boolean

Check if a user is a subscriber of the specified list

Overloads:

  • #list_subscriber?(list, user_to_check, options = {}) ⇒ Boolean

    Returns true if user is a subscriber of the specified list, otherwise false.

    Examples:

    Check if @BarackObama is a subscriber of the authenticated user's "presidents" list

    Twitter.list_subscriber?('presidents', 813286)
    Twitter.list_subscriber?(8863586, 813286)
    Twitter.list_subscriber?('presidents', 'BarackObama')

    Parameters:

    • list (Integer, String)

      The list_id or slug of the list.

    • user_to_check (Integer, String)

      The user ID or screen_name of the list member.

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

      A customizable set of options.

    Returns:

    • (Boolean)

      true if user is a subscriber of the specified list, otherwise false.

    Raises:

  • #list_subscriber?(user, list, user_to_check, options = {}) ⇒ Boolean

    Returns true if user is a subscriber of the specified list, otherwise false.

    Examples:

    Check if @BarackObama is a subscriber of @sferik's "presidents" list

    Twitter.list_subscriber?("sferik", 'presidents', 813286)
    Twitter.list_subscriber?("sferik", 8863586, 813286)
    Twitter.list_subscriber?(7505382, 'presidents', 813286)
    Twitter.list_subscriber?("sferik", 'presidents', 'BarackObama')

    Parameters:

    • user (Integer, String)

      A Twitter user ID or screen name.

    • list (Integer, String)

      The list_id or slug of the list.

    • user_to_check (Integer, String)

      The user ID or screen_name of the list member.

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

      A customizable set of options.

    Returns:

    • (Boolean)

      true if user is a subscriber of the specified list, otherwise false.

    Raises:

Returns:

  • (Boolean)

    true if user is a subscriber of the specified list, otherwise false.

See Also:

Rate Limited?:

  • Yes

Requires Authentication?:

  • Yes



280
281
282
283
284
285
286
287
288
289
290
291
292
# File 'lib/twitter/client/lists.rb', line 280

def list_subscriber?(*args)
  options = args.last.is_a?(Hash) ? args.pop : {}
  user_to_check = args.pop
  options.merge_user!(user_to_check)
  list = args.pop
  options.merge_list!(list)
  owner = args.pop || self.current_user.screen_name
  options.merge_owner!(owner)
  get("/1/lists/subscribers/show.json", options, :raw => true)
  true
rescue Twitter::Error::NotFound, Twitter::Error::Forbidden
  false
end

#list_subscribers(list, options = {}) ⇒ Twitter::Cursor #list_subscribers(user, list, options = {}) ⇒ Twitter::Cursor

Returns the subscribers of the specified list

Overloads:

  • #list_subscribers(list, options = {}) ⇒ Twitter::Cursor

    Returns The subscribers of the specified list.

    Examples:

    Return the subscribers of the authenticated user's "presidents" list

    Twitter.list_subscribers('presidents')
    Twitter.list_subscribers(8863586)

    Parameters:

    • list (Integer, String)

      The list_id or slug of the list.

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

      A customizable set of options.

    Options Hash (options):

    • :cursor (Integer) — default: -1

      Breaks the results into pages. Provide values as returned in the response objects's next_cursor and previous_cursor attributes to page back and forth in the list.

    • :include_entities (Boolean, String, Integer)

      Include Tweet Entities when set to true, 't' or 1.

    Returns:

    Raises:

  • #list_subscribers(user, list, options = {}) ⇒ Twitter::Cursor

    Returns The subscribers of the specified list.

    Examples:

    Return the subscribers of @sferik's "presidents" list

    Twitter.list_subscribers("sferik", 'presidents')
    Twitter.list_subscribers("sferik", 8863586)
    Twitter.list_subscribers(7505382, 'presidents')

    Parameters:

    • user (Integer, String)

      A Twitter user ID or screen name.

    • list (Integer, String)

      The list_id or slug of the list.

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

      A customizable set of options.

    Options Hash (options):

    • :cursor (Integer) — default: -1

      Breaks the results into pages. Provide values as returned in the response objects's next_cursor and previous_cursor attributes to page back and forth in the list.

    • :include_entities (Boolean, String, Integer)

      Include Tweet Entities when set to true, 't' or 1.

    Returns:

    Raises:

See Also:

Rate Limited?:

  • Yes

Requires Authentication?:

  • Supported



179
180
181
182
183
184
185
186
187
# File 'lib/twitter/client/lists.rb', line 179

def list_subscribers(*args)
  options = {:cursor => -1}.merge(args.last.is_a?(Hash) ? args.pop : {})
  list = args.pop
  options.merge_list!(list)
  owner = args.pop || self.current_user.screen_name
  options.merge_owner!(owner)
  cursor = get("/1/lists/subscribers.json", options)
  Twitter::Cursor.new(cursor, 'users', Twitter::User)
end

#list_timeline(list, options = {}) ⇒ Array<Twitter::Status> #list_timeline(user, list, options = {}) ⇒ Array<Twitter::Status>

Show tweet timeline for members of the specified list

Overloads:

  • #list_timeline(list, options = {}) ⇒ Array<Twitter::Status>

    Examples:

    Show tweet timeline for members of the authenticated user's "presidents" list

    Twitter.list_timeline("presidents")
    Twitter.list_timeline(8863586)

    Parameters:

    • list (Integer, String)

      The list_id or slug of the list.

    • 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.

    • :per_page (Integer)

      The number of results to retrieve.

    • :page (Integer)

      Specifies the page of results to retrieve.

    • :include_entities (Boolean, String, Integer)

      Include Tweet Entities when set to true, 't' or 1.

    Returns:

  • #list_timeline(user, list, options = {}) ⇒ Array<Twitter::Status>

    Examples:

    Show tweet timeline for members of @sferik's "presidents" list

    Twitter.list_timeline("sferik", "presidents")
    Twitter.list_timeline("sferik", 8863586)
    Twitter.list_timeline(7505382, "presidents")
    Twitter.list_timeline(7505382, 8863586)

    Parameters:

    • user (Integer, String)

      A Twitter user ID or screen name.

    • list (Integer, String)

      The list_id or slug of the list.

    • 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.

    • :per_page (Integer)

      The number of results to retrieve.

    • :page (Integer)

      Specifies the page of results to retrieve.

    • :include_entities (Boolean, String, Integer)

      Include Tweet Entities when set to true, 't' or 1.

    Returns:

See Also:

Rate Limited?:

  • Yes

Requires Authentication?:

  • No



72
73
74
75
76
77
78
79
80
81
# File 'lib/twitter/client/lists.rb', line 72

def list_timeline(*args)
  options = args.last.is_a?(Hash) ? args.pop : {}
  list = args.pop
  options.merge_list!(list)
  owner = args.pop || self.current_user.screen_name
  options.merge_owner!(owner)
  get("/1/lists/statuses.json", options).map do |status|
    Twitter::Status.new(status)
  end
end

#list_unsubscribe(list, options = {}) ⇒ Twitter::List #list_unsubscribe(user, list, options = {}) ⇒ Twitter::List

Unsubscribes the authenticated user form the specified list

Overloads:

  • #list_unsubscribe(list, options = {}) ⇒ Twitter::List

    Returns The specified list.

    Examples:

    Unsubscribe from the authenticated user's "presidents" list

    Twitter.list_unsubscribe('presidents')
    Twitter.list_unsubscribe(8863586)

    Parameters:

    • list (Integer, String)

      The list_id or slug of the list.

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

      A customizable set of options.

    Returns:

    Raises:

  • #list_unsubscribe(user, list, options = {}) ⇒ Twitter::List

    Returns The specified list.

    Examples:

    Unsubscribe from @sferik's "presidents" list

    Twitter.list_unsubscribe("sferik", 'presidents')
    Twitter.list_unsubscribe("sferik", 8863586)
    Twitter.list_unsubscribe(7505382, 'presidents')

    Parameters:

    • user (Integer, String)

      A Twitter user ID or screen name.

    • list (Integer, String)

      The list_id or slug of the list.

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

      A customizable set of options.

    Returns:

    Raises:

See Also:

Rate Limited?:

  • No

Requires Authentication?:

  • Yes



317
318
319
320
321
322
323
324
325
# File 'lib/twitter/client/lists.rb', line 317

def list_unsubscribe(*args)
  options = args.last.is_a?(Hash) ? args.pop : {}
  list = args.pop
  options.merge_list!(list)
  owner = args.pop || self.current_user.screen_name
  options.merge_owner!(owner)
  list = post("/1/lists/subscribers/destroy.json", options)
  Twitter::List.new(list)
end

#list_update(list, options = {}) ⇒ Twitter::List #list_update(user, list, options = {}) ⇒ Twitter::List

Updates the specified list

Overloads:

  • #list_update(list, options = {}) ⇒ Twitter::List

    Returns The created list.

    Examples:

    Update the authenticated user's "presidents" list to have the description "Presidents of the United States of America"

    Twitter.list_update("presidents", :description => "Presidents of the United States of America")
    Twitter.list_update(8863586, :description => "Presidents of the United States of America")

    Parameters:

    • list (Integer, String)

      The list_id or slug for the list.

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

      A customizable set of options.

    Options Hash (options):

    • :mode (String) — default: 'public'

      Whether your list is public or private. Values can be 'public' or 'private'.

    • :description (String)

      The description to give the list.

    Returns:

    Raises:

  • #list_update(user, list, options = {}) ⇒ Twitter::List

    Returns The created list.

    Examples:

    Update the @sferik's "presidents" list to have the description "Presidents of the United States of America"

    Twitter.list_update("sferik", "presidents", :description => "Presidents of the United States of America")
    Twitter.list_update(7505382, "presidents", :description => "Presidents of the United States of America")
    Twitter.list_update("sferik", 8863586, :description => "Presidents of the United States of America")
    Twitter.list_update(7505382, 8863586, :description => "Presidents of the United States of America")

    Parameters:

    • user (Integer, String)

      A Twitter user ID or screen name.

    • list (Integer, String)

      The list_id or slug for the list.

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

      A customizable set of options.

    Options Hash (options):

    • :mode (String) — default: 'public'

      Whether your list is public or private. Values can be 'public' or 'private'.

    • :description (String)

      The description to give the list.

    Returns:

    Raises:

See Also:

Rate Limited?:

  • No

Requires Authentication?:

  • Yes



547
548
549
550
551
552
553
554
555
# File 'lib/twitter/client/lists.rb', line 547

def list_update(*args)
  options = args.last.is_a?(Hash) ? args.pop : {}
  list = args.pop
  options.merge_list!(list)
  owner = args.pop || self.current_user.screen_name
  options.merge_owner!(owner)
  list = post("/1/lists/update.json", options)
  Twitter::List.new(list)
end

#lists(options = {}) ⇒ Twitter::Cursor #lists(user, options = {}) ⇒ Twitter::Cursor

Note:

Private lists will be included if the authenticated user is the same as the user whose lists are being returned.

List the lists of the specified user

Overloads:

  • #lists(options = {}) ⇒ Twitter::Cursor

    Examples:

    List the authenticated user's lists

    Twitter.lists

    Parameters:

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

      A customizable set of options.

    Options Hash (options):

    • :cursor (Integer) — default: -1

      Breaks the results into pages. Provide values as returned in the response objects's next_cursor and previous_cursor attributes to page back and forth in the list.

    Returns:

    Raises:

  • #lists(user, options = {}) ⇒ Twitter::Cursor

    Examples:

    List @sferik's lists

    Twitter.lists("sferik")
    Twitter.lists(7505382)

    Parameters:

    • user (Integer, String)

      A Twitter user ID or screen name.

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

      A customizable set of options.

    Options Hash (options):

    • :cursor (Integer) — default: -1

      Breaks the results into pages. Provide values as returned in the response objects's next_cursor and previous_cursor attributes to page back and forth in the list.

    Returns:

    Raises:

See Also:

Rate Limited?:

  • Yes

Requires Authentication?:

  • Yes



598
599
600
601
602
603
604
# File 'lib/twitter/client/lists.rb', line 598

def lists(*args)
  options = {:cursor => -1}.merge(args.last.is_a?(Hash) ? args.pop : {})
  user = args.first
  options.merge_user!(user) if user
  cursor = get("/1/lists.json", options)
  Twitter::Cursor.new(cursor, 'lists', Twitter::List)
end

#lists_subscribed_to(options = {}) ⇒ Array<Twitter::Status> #lists_subscribed_to(user, options = {}) ⇒ Array<Twitter::List>

Returns all lists the authenticating or specified user subscribes to, including their own

Overloads:

  • #lists_subscribed_to(options = {}) ⇒ Array<Twitter::Status>

    Examples:

    Return all lists the authenticating user subscribes to

    Twitter.lists_subscribed_to

    Parameters:

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

      A customizable set of options.

    Returns:

  • #lists_subscribed_to(user, options = {}) ⇒ Array<Twitter::List>

    Examples:

    Return all lists the specified user subscribes to

    Twitter.lists_subscribed_to("sferik")
    Twitter.lists_subscribed_to(8863586)

    Parameters:

    • user (Integer, String)

      A Twitter user ID or screen name.

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

      A customizable set of options.

    Returns:

See Also:

Rate Limited?:

  • Yes

Requires Authentication?:

  • Supported



30
31
32
33
34
35
36
37
38
# File 'lib/twitter/client/lists.rb', line 30

def lists_subscribed_to(*args)
  options = args.last.is_a?(Hash) ? args.pop : {}
  if user = args.pop
    options.merge_user!(user)
  end
  get("/1/lists/all.json", options).map do |list|
    Twitter::List.new(list)
  end
end

#memberships(options = {}) ⇒ Twitter::Cursor #memberships(user, options = {}) ⇒ Twitter::Cursor

List the lists the specified user has been added to

Overloads:

  • #memberships(options = {}) ⇒ Twitter::Cursor

    Examples:

    List the lists the authenticated user has been added to

    Twitter.memberships

    Parameters:

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

      A customizable set of options.

    Options Hash (options):

    • :cursor (Integer) — default: -1

      Breaks the results into pages. Provide values as returned in the response objects's next_cursor and previous_cursor attributes to page back and forth in the list.

    Returns:

    Raises:

  • #memberships(user, options = {}) ⇒ Twitter::Cursor

    Examples:

    List the lists that @sferik has been added to

    Twitter.memberships("sferik")
    Twitter.memberships(7505382)

    Parameters:

    • user (Integer, String)

      A Twitter user ID or screen name.

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

      A customizable set of options.

    Options Hash (options):

    • :cursor (Integer) — default: -1

      Breaks the results into pages. Provide values as returned in the response objects's next_cursor and previous_cursor attributes to page back and forth in the list.

    Returns:

    Raises:

See Also:

Rate Limited?:

  • Yes

Requires Authentication?:

  • Supported



143
144
145
146
147
148
149
150
# File 'lib/twitter/client/lists.rb', line 143

def memberships(*args)
  options = {:cursor => -1}.merge(args.last.is_a?(Hash) ? args.pop : {})
  if user = args.pop
    options.merge_user!(user)
  end
  cursor = get("/1/lists/memberships.json", options)
  Twitter::Cursor.new(cursor, 'lists', Twitter::List)
end

#subscriptions(options = {}) ⇒ Twitter::Cursor #subscriptions(user, options = {}) ⇒ Twitter::Cursor

List the lists the specified user follows

Overloads:

  • #subscriptions(options = {}) ⇒ Twitter::Cursor

    Examples:

    List the lists the authenticated user follows

    Twitter.subscriptions

    Parameters:

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

      A customizable set of options.

    Options Hash (options):

    • :cursor (Integer) — default: -1

      Breaks the results into pages. Provide values as returned in the response objects's next_cursor and previous_cursor attributes to page back and forth in the list.

    Returns:

    Raises:

  • #subscriptions(user, options = {}) ⇒ Twitter::Cursor

    Examples:

    List the lists that @sferik follows

    Twitter.subscriptions("sferik")
    Twitter.subscriptions(7505382)

    Parameters:

    • user (Integer, String)

      A Twitter user ID or screen name.

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

      A customizable set of options.

    Options Hash (options):

    • :cursor (Integer) — default: -1

      Breaks the results into pages. Provide values as returned in the response objects's next_cursor and previous_cursor attributes to page back and forth in the list.

    Returns:

    Raises:

See Also:

Rate Limited?:

  • Yes

Requires Authentication?:

  • Supported



210
211
212
213
214
215
216
217
# File 'lib/twitter/client/lists.rb', line 210

def subscriptions(*args)
  options = {:cursor => -1}.merge(args.last.is_a?(Hash) ? args.pop : {})
  if user = args.pop
    options.merge_user!(user)
  end
  cursor = get("/1/lists/subscriptions.json", options)
  Twitter::Cursor.new(cursor, 'lists', Twitter::List)
end