### Home Classes Methods

### In Files

- lib/twitter/rest/friends_and_followers.rb

### Methods

- #create_friendship
- #create_friendship!
- #destroy_friendship
- #follow
- #follow!
- #follower_ids
- #followers
- #following
- #friend_ids
- #friends
- #friendship
- #friendship?
- #friendship_show
- #friendship_update
- #friendships
- #friendships_incoming
- #friendships_outgoing
- #no_retweet_ids
- #no_retweets_ids
- #relationship
- #unfollow

### Included Modules

- Twitter::REST::Utils
- Twitter::Utils

### 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::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::REST::FriendsAndFollowers

### Public Instance Methods

create_friendship(*args) click to toggle source
Alias for: follow
create_friendship!(*args) click to toggle source
Alias for: follow!
destroy_friendship(*args) click to toggle source
Alias for: unfollow
follow(*args) click to toggle source

Allows the authenticating user to follow the specified users, unless they are already followed

@see dev.twitter.com/docs/api/1.1/post/friendships/create @rate_limited Yes @authentication Requires user context @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid. @return [Array<Twitter::User>] The followed users. @overload follow(*users)

    @param users [Enumerable<Integer, String, Twitter::User>] A collection of Twitter user IDs, screen names, or objects.

@overload follow(*users, options)

    @param users [Enumerable<Integer, String, Twitter::User>] A collection of Twitter user IDs, screen names, or objects.
    @param options [Hash] A customizable set of options.
    @option options [Boolean] :follow (false) Enable notifications for the target user.

    # File lib/twitter/rest/friends_and_followers.rb, line 106
    def follow(*args)
      arguments = Twitter::Arguments.new(args)
      existing_friends = Thread.new do
        friend_ids.to_a
      end
      new_friends = Thread.new do
        users(args).collect(&:id)
      end
      follow!(new_friends.value - existing_friends.value, arguments.options)
    end

Also aliased as: create_friendship
follow!(*args) click to toggle source

Allows the authenticating user to follow the specified users

@see dev.twitter.com/docs/api/1.1/post/friendships/create @rate_limited No @authentication Requires user context @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid. @return [Array<Twitter::User>] The followed users. @overload follow!(*users)

    @param users [Enumerable<Integer, String, Twitter::User>] A collection of Twitter user IDs, screen names, or objects.

@overload follow!(*users, options)

    @param users [Enumerable<Integer, String, Twitter::User>] A collection of Twitter user IDs, screen names, or objects.
    @param options [Hash] A customizable set of options.
    @option options [Boolean] :follow (false) Enable notifications for the target user.

    # File lib/twitter/rest/friends_and_followers.rb, line 132
    def follow!(*args)
      arguments = Twitter::Arguments.new(args)
      pmap(arguments) do |user|
        perform_with_object(:post, '/1.1/friendships/create.json', merge_user(arguments.options, user), Twitter::User)
      end.compact
    end

Also aliased as: create_friendship!
follower_ids(*args) click to toggle source

@see dev.twitter.com/docs/api/1.1/get/followers/ids @rate_limited Yes @authentication Requires user context @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid. @return [Twitter::Cursor] @overload follower_ids(options = {})

    Returns an array of numeric IDs for every user following the authenticated user

    @param options [Hash] A customizable set of options.

@overload follower_ids(user, options = {})

    Returns an array of numeric IDs for every user following the specified user

    @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, URI, or object.
    @param options [Hash] A customizable set of options.

    # File lib/twitter/rest/friends_and_followers.rb, line 47
    def follower_ids(*args)
      cursor_from_response_with_user(:ids, nil, :get, '/1.1/followers/ids.json', args)
    end

followers(*args) click to toggle source

Returns a cursored collection of user objects for users following the specified user.

@see dev.twitter.com/docs/api/1.1/get/followers/list @rate_limited Yes @authentication Requires user context @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid. @return [Twitter::Cursor] @overload followers(options = {})

    Returns a cursored collection of user objects for users following the authenticated user.

    @param options [Hash] A customizable set of options.
    @option options [Boolean, String, Integer] :skip_status Do not include contributee's Tweets when set to true, 't' or 1.
    @option options [Boolean, String, Integer] :include_user_entities The user entities node will be disincluded when set to false.

@overload followers(user, options = {})

    Returns a cursored collection of user objects for users following the specified user.

    @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, URI, or object.
    @param options [Hash] A customizable set of options.
    @option options [Boolean, String, Integer] :skip_status Do not include contributee's Tweets when set to true, 't' or 1.
    @option options [Boolean, String, Integer] :include_user_entities The user entities node will be disincluded when set to false.

    # File lib/twitter/rest/friends_and_followers.rb, line 229
    def followers(*args)
      cursor_from_response_with_user(:users, Twitter::User, :get, '/1.1/followers/list.json', args)
    end

following(*args) click to toggle source
Alias for: friends
friend_ids(*args) click to toggle source

@see dev.twitter.com/docs/api/1.1/get/friends/ids @rate_limited Yes @authentication Requires user context @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid. @return [Twitter::Cursor] @overload friend_ids(options = {})

    Returns an array of numeric IDs for every user the authenticated user is following

    @param options [Hash] A customizable set of options.

@overload friend_ids(user, options = {})

    Returns an array of numeric IDs for every user the specified user is following

    @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, URI, or object.
    @param options [Hash] A customizable set of options.

    # File lib/twitter/rest/friends_and_followers.rb, line 29
    def friend_ids(*args)
      cursor_from_response_with_user(:ids, nil, :get, '/1.1/friends/ids.json', args)
    end

friends(*args) click to toggle source

Returns a cursored collection of user objects for every user the specified user is following (otherwise known as their "friends").

@see dev.twitter.com/docs/api/1.1/get/friends/list @rate_limited Yes @authentication Requires user context @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid. @return [Twitter::Cursor] @overload friends(options = {})

    Returns a cursored collection of user objects for every user the authenticated user is following (otherwise known as their "friends").

    @param options [Hash] A customizable set of options.
    @option options [Boolean, String, Integer] :skip_status Do not include contributee's Tweets when set to true, 't' or 1.
    @option options [Boolean, String, Integer] :include_user_entities The user entities node will be disincluded when set to false.

@overload friends(user, options = {})

    Returns a cursored collection of user objects for every user the specified user is following (otherwise known as their "friends").

    @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, URI, or object.
    @param options [Hash] A customizable set of options.
    @option options [Boolean, String, Integer] :skip_status Do not include contributee's Tweets when set to true, 't' or 1.
    @option options [Boolean, String, Integer] :include_user_entities The user entities node will be disincluded when set to false.

    # File lib/twitter/rest/friends_and_followers.rb, line 253
    def friends(*args)
      cursor_from_response_with_user(:users, Twitter::User, :get, '/1.1/friends/list.json', args)
    end

Also aliased as: following
friendship(source, target, options = {}) click to toggle source

Returns detailed information about the relationship between two users

@see dev.twitter.com/docs/api/1.1/get/friendships/show @rate_limited Yes @authentication Requires user context @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid. @return [Twitter::Relationship] @param source [Integer, String, Twitter::User] The Twitter user ID, screen name, or object of the source user. @param target [Integer, String, Twitter::User] The Twitter user ID, screen name, or object of the target user. @param options [Hash] A customizable set of options.

    # File lib/twitter/rest/friends_and_followers.rb, line 185
    def friendship(source, target, options = {})
      merge_user!(options, source, 'source')
      options[:source_id] = options.delete(:source_user_id) unless options[:source_user_id].nil?
      merge_user!(options, target, 'target')
      options[:target_id] = options.delete(:target_user_id) unless options[:target_user_id].nil?
      perform_with_object(:get, '/1.1/friendships/show.json', options, Twitter::Relationship)
    end

Also aliased as: friendship_show, relationship
friendship?(source, target, options = {}) click to toggle source

Test for the existence of friendship between two users

@see dev.twitter.com/docs/api/1.1/get/friendships/show @rate_limited Yes @authentication Requires user context @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid. @return [Boolean] true if user_a follows user_b, otherwise false. @param source [Integer, String, Twitter::User] The Twitter user ID, screen name, or object of the source user. @param target [Integer, String, Twitter::User] The Twitter user ID, screen name, or object of the target user. @param options [Hash] A customizable set of options.

    # File lib/twitter/rest/friends_and_followers.rb, line 205
    def friendship?(source, target, options = {})
      friendship(source, target, options).source.following?
    end

friendship_show(source, target, options = {}) click to toggle source
Alias for: friendship
friendship_update(user, options = {}) click to toggle source

Allows one to enable or disable retweets and device notifications from the specified user.

@see dev.twitter.com/docs/api/1.1/post/friendships/update @rate_limited No @authentication Requires user context @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid. @return [Twitter::Relationship] @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, URI, or object. @param options [Hash] A customizable set of options. @option options [Boolean] :device Enable/disable device notifications from the target user. @option options [Boolean] :retweets Enable/disable retweets from the target user.

    # File lib/twitter/rest/friends_and_followers.rb, line 170
    def friendship_update(user, options = {})
      merge_user!(options, user)
      perform_with_object(:post, '/1.1/friendships/update.json', options, Twitter::Relationship)
    end

friendships(*args) click to toggle source

Returns the relationship of the authenticating user to the comma separated list of up to 100 screen_names or user_ids provided. Values for connections can be: following, following_requested, followed_by, none.

@see dev.twitter.com/docs/api/1.1/get/friendships/lookup @rate_limited Yes @authentication Requires user context @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid. @return [Array<Twitter::User>] The requested users. @overload friendships(*users)

    @param users [Enumerable<Integer, String, Twitter::User>] A collection of Twitter user IDs, screen names, or objects.

@overload friendships(*users, options)

    @param users [Enumerable<Integer, String, Twitter::User>] A collection of Twitter user IDs, screen names, or objects.
    @param options [Hash] A customizable set of options.

    # File lib/twitter/rest/friends_and_followers.rb, line 63
    def friendships(*args)
      arguments = Twitter::Arguments.new(args)
      merge_users!(arguments.options, arguments)
      perform_with_objects(:get, '/1.1/friendships/lookup.json', arguments.options, Twitter::User)
    end

friendships_incoming(options = {}) click to toggle source

Returns an array of numeric IDs for every user who has a pending request to follow the authenticating user

@see dev.twitter.com/docs/api/1.1/get/friendships/incoming @rate_limited Yes @authentication Requires user context @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid. @return [Twitter::Cursor] @param options [Hash] A customizable set of options.

    # File lib/twitter/rest/friends_and_followers.rb, line 77
    def friendships_incoming(options = {})
      perform_with_cursor(:get, '/1.1/friendships/incoming.json', options, :ids)
    end

friendships_outgoing(options = {}) click to toggle source

Returns an array of numeric IDs for every protected user for whom the authenticating user has a pending follow request

@see dev.twitter.com/docs/api/1.1/get/friendships/outgoing @rate_limited Yes @authentication Requires user context @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid. @return [Twitter::Cursor] @param options [Hash] A customizable set of options.

    # File lib/twitter/rest/friends_and_followers.rb, line 89
    def friendships_outgoing(options = {})
      perform_with_cursor(:get, '/1.1/friendships/outgoing.json', options, :ids)
    end

no_retweet_ids(options = {}) click to toggle source

Returns a collection of user IDs that the currently authenticated user does not want to receive retweets from. @see dev.twitter.com/docs/api/1.1/get/friendships/no_retweets/ids @rate_limited Yes @authentication Requires user context @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid. @return [Array<Integer>] @param options [Hash] A customizable set of options.

    # File lib/twitter/rest/friends_and_followers.rb, line 265
    def no_retweet_ids(options = {})
      get('/1.1/friendships/no_retweets/ids.json', options).body.collect(&:to_i)
    end

Also aliased as: no_retweets_ids
no_retweets_ids(options = {}) click to toggle source
Alias for: no_retweet_ids
relationship(source, target, options = {}) click to toggle source
Alias for: friendship
unfollow(*args) click to toggle source

Allows the authenticating user to unfollow the specified users

@see dev.twitter.com/docs/api/1.1/post/friendships/destroy @rate_limited No @authentication Requires user context @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid. @return [Array<Twitter::User>] The unfollowed users. @overload unfollow(*users)

    @param users [Enumerable<Integer, String, Twitter::User>] A collection of Twitter user IDs, screen names, or objects.

@overload unfollow(*users, options)

    @param users [Enumerable<Integer, String, Twitter::User>] A collection of Twitter user IDs, screen names, or objects.
    @param options [Hash] A customizable set of options.

    # File lib/twitter/rest/friends_and_followers.rb, line 153
    def unfollow(*args)
      parallel_users_from_response(:post, '/1.1/friendships/destroy.json', args)
    end

Also aliased as: destroy_friendship

[Validate]

Generated with the Darkfish Rdoc Generator 2.