Module: Twitter::API
- Included in:
- Client
- Defined in:
- lib/twitter/api.rb
Constant Summary collapse
- DEFAULT_CURSOR =
-1
- DEFAULT_TWEETS_PER_REQUEST =
20
- MAX_USERS_PER_REQUEST =
100
- MAX_TWEETS_PER_REQUEST =
200
Instance Method Summary collapse
-
#activity_about_me(options = {}) ⇒ Array
Returns activity about me.
-
#activity_by_friends(options = {}) ⇒ Array
Returns activity by friends.
-
#block(*args) ⇒ Array<Twitter::User>
Blocks the users specified by the authenticating user.
-
#block?(user, options = {}) ⇒ Boolean
Returns true if the authenticating user is blocking a target user.
-
#blocked_ids(*args) ⇒ Array
Returns an array of numeric user ids the authenticating user is blocking.
-
#blocking(options = {}) ⇒ Array<Twitter::User>
Returns an array of user objects that the authenticating user is blocking.
-
#configuration(options = {}) ⇒ Twitter::Configuration
Returns the current configuration used by Twitter.
-
#contributees(*args) ⇒ Array<Twitter::User>
Returns an array of users that the specified user can contribute to.
-
#contributors(*args) ⇒ Array<Twitter::User>
Returns an array of users who can contribute to the specified account.
-
#direct_message(id, options = {}) ⇒ Twitter::DirectMessage
Returns a direct message.
-
#direct_message_create(user, text, options = {}) ⇒ Twitter::DirectMessage
(also: #d, #m)
Sends a new direct message to the specified user from the authenticating user.
-
#direct_message_destroy(*args) ⇒ Array<Twitter::DirectMessage>
Destroys direct messages.
-
#direct_messages(*args) ⇒ Array<Twitter::DirectMessage>
The requested messages.
-
#direct_messages_received(options = {}) ⇒ Array<Twitter::DirectMessage>
Returns the 20 most recent direct messages sent to the authenticating user.
-
#direct_messages_sent(options = {}) ⇒ Array<Twitter::DirectMessage>
Returns the 20 most recent direct messages sent by the authenticating user.
-
#favorite(*args) ⇒ Array<Twitter::Tweet>
(also: #fav, #fave, #favorite_create)
Favorites the specified Tweets as the authenticating user.
-
#favorites(*args) ⇒ Array<Twitter::Tweet>
Favorite Tweets.
-
#follow(*args) ⇒ Array<Twitter::User>
(also: #friendship_create)
Allows the authenticating user to follow the specified users, unless they are already followed.
-
#follow!(*args) ⇒ Array<Twitter::User>
(also: #friendship_create!)
Allows the authenticating user to follow the specified users.
- #follower_ids(*args) ⇒ Twitter::Cursor
- #following_followers_of(*args) ⇒ Object
- #friend_ids(*args) ⇒ Twitter::Cursor
-
#friendship(source, target, options = {}) ⇒ Twitter::Relationship
(also: #friendship_show, #relationship)
Returns detailed information about the relationship between two users.
-
#friendship?(source, target, options = {}) ⇒ Boolean
Test for the existence of friendship between two users.
-
#friendship_update(user, options = {}) ⇒ Twitter::Relationship
Allows one to enable or disable retweets and device notifications from the specified user.
-
#friendships(*args) ⇒ Array<Twitter::User>
Returns the relationship of the authenticating user to the comma separated list of up to 100 screen_names or user_ids provided.
-
#friendships_incoming(options = {}) ⇒ Twitter::Cursor
Returns an array of numeric IDs for every user who has a pending request to follow the authenticating user.
-
#friendships_outgoing(options = {}) ⇒ Twitter::Cursor
Returns an array of numeric IDs for every protected user for whom the authenticating user has a pending follow request.
-
#home_timeline(options = {}) ⇒ Array<Twitter::Tweet>
Returns the 20 most recent Tweets, including retweets if they exist, posted by the authenticating user and the users they follow.
-
#languages(options = {}) ⇒ Array<Twitter::Language>
Returns the list of languages supported by Twitter.
-
#list(*args) ⇒ Twitter::List
Show the specified list.
-
#list_add_member(*args) ⇒ Twitter::List
Add a member to a list.
-
#list_add_members(*args) ⇒ Twitter::List
Adds specified members to a list.
-
#list_create(name, options = {}) ⇒ Twitter::List
Creates a new list for the authenticated user.
-
#list_destroy(*args) ⇒ Twitter::List
Deletes the specified list.
-
#list_member?(*args) ⇒ Boolean
Check if a user is a member of the specified list.
-
#list_members(*args) ⇒ Twitter::Cursor
Returns the members of the specified list.
-
#list_remove_member(*args) ⇒ Twitter::List
Removes the specified member from the list.
-
#list_remove_members(*args) ⇒ Twitter::List
Removes specified members from the list.
-
#list_subscribe(*args) ⇒ Twitter::List
Make the authenticated user follow the specified list.
-
#list_subscriber?(*args) ⇒ Boolean
Check if a user is a subscriber of the specified list.
-
#list_subscribers(*args) ⇒ Twitter::Cursor
Returns the subscribers of the specified list.
-
#list_timeline(*args) ⇒ Array<Twitter::Tweet>
Show tweet timeline for members of the specified list.
-
#list_unsubscribe(*args) ⇒ Twitter::List
Unsubscribes the authenticated user form the specified list.
-
#list_update(*args) ⇒ Twitter::List
Updates the specified list.
-
#lists(*args) ⇒ Twitter::Cursor
(also: #lists_subscribed_to)
List the lists of the specified user Returns all lists the authenticating or specified user subscribes to, including their own.
-
#media_timeline(user, options = {}) ⇒ Array<Twitter::Tweet>
Returns the 20 most recent images posted by the specified user.
-
#memberships(*args) ⇒ Twitter::Cursor
List the lists the specified user has been added to.
-
#mentions_timeline(options = {}) ⇒ Array<Twitter::Tweet>
(also: #mentions)
Returns the 20 most recent mentions (statuses containing @username) for the authenticating user.
-
#oembed(id, options = {}) ⇒ Twitter::OEmbed
Returns oEmbed for a Tweet.
-
#oembeds(*args) ⇒ Array<Twitter::OEmbed>
Returns oEmbeds for Tweets.
-
#phoenix_search(q, options = {}) ⇒ Array<Twitter::Tweet>
Returns recent Tweets related to a query with images and videos embedded.
-
#place(place_id, options = {}) ⇒ Twitter::Place
Returns all the information about a known place.
-
#place_create(options = {}) ⇒ Twitter::Place
Creates a new place at the given latitude and longitude.
-
#places_nearby(options = {}) ⇒ Array<Twitter::Place>
(also: #geo_search)
Search for places that can be attached to a Statuses#update.
-
#places_similar(options = {}) ⇒ Array<Twitter::Place>
Locates places near the given coordinates which are similar in name.
-
#privacy(options = {}) ⇒ String
Returns Twitter’s Privacy Policy.
-
#report_spam(*args) ⇒ Array<Twitter::User>
The users specified are blocked by the authenticated user and reported as spammers.
-
#retweet(*args) ⇒ Array<Twitter::Tweet>
Retweets tweets.
-
#retweeted_by_me(options = {}) ⇒ Array<Twitter::Tweet>
Returns the 20 most recent retweets posted by the authenticating user.
-
#retweeted_by_user(user, options = {}) ⇒ Array<Twitter::Tweet>
(also: #retweeted_by)
Returns the 20 most recent retweets posted by the specified user.
-
#retweeted_to_me(options = {}) ⇒ Array<Twitter::Tweet>
Returns the 20 most recent retweets posted by users the authenticating user follow.
-
#retweeters_of(id, options = {}) ⇒ Array
Show up to 100 users who retweeted the Tweet.
-
#retweets(id, options = {}) ⇒ Array<Twitter::Tweet>
Returns up to 100 of the first retweets of a given tweet.
-
#retweets_of_me(options = {}) ⇒ Array<Twitter::Tweet>
Returns the 20 most recent tweets of the authenticated user that have been retweeted by others.
-
#reverse_geocode(options = {}) ⇒ Array<Twitter::Place>
Searches for up to 20 places that can be used as a place_id.
-
#saved_search(id, options = {}) ⇒ Twitter::SavedSearch
Retrieve the data for saved searches owned by the authenticating user.
-
#saved_search_create(query, options = {}) ⇒ Twitter::SavedSearch
Creates a saved search for the authenticated user.
-
#saved_search_destroy(*args) ⇒ Array<Twitter::SavedSearch>
Destroys saved searches for the authenticated user.
-
#saved_searches(*args) ⇒ Array<Twitter::SavedSearch>
The saved searches.
-
#search(q, options = {}) ⇒ Twitter::SearchResults
Returns tweets that match a specified query.
-
#settings(options = {}) ⇒ Twitter::Settings
Updates the authenticating user’s settings.
-
#status(id, options = {}) ⇒ Twitter::Tweet
Returns a Tweet.
-
#status_activity(id, options = {}) ⇒ Twitter::Tweet
(also: #tweet_activity)
Returns activity summary for a Tweet.
-
#status_destroy(*args) ⇒ Array<Twitter::Tweet>
(also: #tweet_destroy)
Destroys the specified Tweets.
-
#statuses(*args) ⇒ Array<Twitter::Tweet>
Returns Tweets.
-
#statuses_activity(*args) ⇒ Array<Twitter::Tweet>
Returns activity summary for Tweets.
-
#subscriptions(*args) ⇒ Twitter::Cursor
List the lists the specified user follows.
-
#suggest_users(slug, options = {}) ⇒ Array<Twitter::User>
Access the users in a given category of the Twitter suggested user list and return their most recent Tweet if they are not a protected user.
- #suggestions(*args) ⇒ Array<Twitter::Suggestion>
-
#tos(options = {}) ⇒ String
Returns Twitter’s Terms of Service.
-
#trends(id = 1, options = {}) ⇒ Array<Twitter::Trend>
(also: #local_trends, #trends_place)
Returns the top 10 trending topics for a specific WOEID.
-
#trends_available(options = {}) ⇒ Array<Twitter::Place>
(also: #trend_locations)
Returns the locations that Twitter has trending topic information for.
-
#trends_closest(options = {}) ⇒ Array<Twitter::Place>
Returns the locations that Twitter has trending topic information for, closest to a specified location.
-
#unblock(*args) ⇒ Array<Twitter::User>
Un-blocks the users specified by the authenticating user.
-
#unfavorite(*args) ⇒ Array<Twitter::Tweet>
(also: #favorite_destroy)
Un-favorites the specified Tweets as the authenticating user.
-
#unfollow(*args) ⇒ Array<Twitter::User>
(also: #friendship_destroy)
Allows the authenticating user to unfollow the specified users.
-
#update(status, options = {}) ⇒ Twitter::Tweet
Updates the authenticating user’s status.
-
#update_delivery_device(device, options = {}) ⇒ Twitter::User
Sets which device Twitter delivers updates to for the authenticating user.
-
#update_profile(options = {}) ⇒ Twitter::User
Sets values that users are able to set under the “Account” tab of their settings page.
-
#update_profile_background_image(image, options = {}) ⇒ Twitter::User
Updates the authenticating user’s profile background image.
-
#update_profile_colors(options = {}) ⇒ Twitter::User
Sets one or more hex values that control the color scheme of the authenticating user’s profile.
-
#update_profile_image(image, options = {}) ⇒ Twitter::User
Updates the authenticating user’s profile image.
-
#update_with_media(status, media, options = {}) ⇒ Twitter::Tweet
Updates the authenticating user’s status with media.
-
#user(*args) ⇒ Twitter::User
The requested user.
-
#user?(user, options = {}) ⇒ Boolean
Returns true if the specified user exists.
-
#user_search(query, options = {}) ⇒ Array<Twitter::User>
Returns users that match the given query.
-
#user_timeline(user, options = {}) ⇒ Array<Twitter::Tweet>
Returns the 20 most recent Tweets posted by the specified user.
-
#users(*args) ⇒ Array<Twitter::User>
Returns extended information for up to 100 users.
-
#verify_credentials(options = {}) ⇒ Twitter::User
(also: #current_user)
Returns the requesting user if authentication was successful, otherwise raises Error::Unauthorized.
Instance Method Details
#activity_about_me(options = {}) ⇒ Array
Undocumented
Returns activity about me
167 168 169 |
# File 'lib/twitter/api.rb', line 167 def activity_about_me(={}) collection_from_response(Twitter::ActionFactory, :get, "/i/activity/about_me.json", ) end |
#activity_by_friends(options = {}) ⇒ Array
Undocumented
Returns activity by friends
183 184 185 |
# File 'lib/twitter/api.rb', line 183 def activity_by_friends(={}) collection_from_response(Twitter::ActionFactory, :get, "/i/activity/by_friends.json", ) end |
#block(*users) ⇒ Array<Twitter::User> #block(*users, options) ⇒ Array<Twitter::User>
Destroys a friendship to the blocked user if it exists.
Blocks the users specified by the authenticating user
2000 2001 2002 |
# File 'lib/twitter/api.rb', line 2000 def block(*args) threaded_users_from_response(:post, "/1.1/blocks/create.json", args) end |
#block?(user, options = {}) ⇒ Boolean
Returns true if the authenticating user is blocking a target user
1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 |
# File 'lib/twitter/api.rb', line 1971 def block?(user, ={}) merge_default_cursor!() user_id = case user when Integer user when String user(user).id when Twitter::User user.id end blocked_ids().all.map(&:to_i).include?(user_id) end |
#blocked_ids(*args) ⇒ Array
Returns an array of numeric user ids the authenticating user is blocking
1955 1956 1957 |
# File 'lib/twitter/api.rb', line 1955 def blocked_ids(*args) ids_from_response(:get, "/1.1/blocks/ids.json", args) end |
#blocking(options = {}) ⇒ Array<Twitter::User>
Returns an array of user objects that the authenticating user is blocking
1940 1941 1942 1943 |
# File 'lib/twitter/api.rb', line 1940 def blocking(={}) merge_default_cursor!() cursor_from_response(:users, Twitter::User, :get, "/1.1/blocks/list.json", ) end |
#configuration(options = {}) ⇒ Twitter::Configuration
Returns the current configuration used by Twitter
678 679 680 |
# File 'lib/twitter/api.rb', line 678 def configuration(={}) object_from_response(Twitter::Configuration, :get, "/1.1/help/configuration.json", ) end |
#contributees(options = {}) ⇒ Array<Twitter::User> #contributees(user, options = {}) ⇒ Array<Twitter::User>
Returns an array of users that the specified user can contribute to
2171 2172 2173 |
# File 'lib/twitter/api.rb', line 2171 def contributees(*args) users_from_response(:get, "/1.1/users/contributees.json", args) end |
#contributors(options = {}) ⇒ Array<Twitter::User> #contributors(user, options = {}) ⇒ Array<Twitter::User>
Returns an array of users who can contribute to the specified account
2194 2195 2196 |
# File 'lib/twitter/api.rb', line 2194 def contributors(*args) users_from_response(:get, "/1.1/users/contributors.json", args) end |
#direct_message(id, options = {}) ⇒ Twitter::DirectMessage
This method requires an access token with RWD (read, write & direct message) permissions. Consult The Application Permission Model for more information.
Returns a direct message
280 281 282 283 |
# File 'lib/twitter/api.rb', line 280 def (id, ={}) [:id] = id object_from_response(Twitter::DirectMessage, :get, "/1.1/direct_messages/show.json", ) end |
#direct_message_create(user, text, options = {}) ⇒ Twitter::DirectMessage Also known as: d, m
Sends a new direct message to the specified user from the authenticating user
260 261 262 263 264 |
# File 'lib/twitter/api.rb', line 260 def (user, text, ={}) .merge_user!(user) [:text] = text object_from_response(Twitter::DirectMessage, :post, "/1.1/direct_messages/new.json", ) end |
#direct_message_destroy(*ids) ⇒ Array<Twitter::DirectMessage> #direct_message_destroy(*ids, options) ⇒ Array<Twitter::DirectMessage>
This method requires an access token with RWD (read, write & direct message) permissions. Consult The Application Permission Model for more information.
Destroys direct messages
240 241 242 243 244 245 |
# File 'lib/twitter/api.rb', line 240 def (*args) = args. args.flatten.threaded_map do |id| object_from_response(Twitter::DirectMessage, :post, "/1.1/direct_messages/destroy.json", .merge(:id => id)) end end |
#direct_messages(options = {}) ⇒ Array<Twitter::DirectMessage> #direct_messages(*ids) ⇒ Array<Twitter::DirectMessage> #direct_messages(*ids, options) ⇒ Array<Twitter::DirectMessage>
This method requires an access token with RWD (read, write & direct message) permissions. Consult The Application Permission Model for more information.
Returns The requested messages.
314 315 316 317 318 319 320 321 322 323 |
# File 'lib/twitter/api.rb', line 314 def (*args) = args. if args.empty? () else args.flatten.threaded_map do |id| (id, ) end end end |
#direct_messages_received(options = {}) ⇒ Array<Twitter::DirectMessage>
This method requires an access token with RWD (read, write & direct message) permissions. Consult The Application Permission Model for more information.
Returns the 20 most recent direct messages sent to the authenticating user
202 203 204 |
# File 'lib/twitter/api.rb', line 202 def (={}) collection_from_response(Twitter::DirectMessage, :get, "/1.1/direct_messages.json", ) end |
#direct_messages_sent(options = {}) ⇒ Array<Twitter::DirectMessage>
This method requires an access token with RWD (read, write & direct message) permissions. Consult The Application Permission Model for more information.
Returns the 20 most recent direct messages sent by the authenticating user
221 222 223 |
# File 'lib/twitter/api.rb', line 221 def (={}) collection_from_response(Twitter::DirectMessage, :get, "/1.1/direct_messages/sent.json", ) end |
#favorite(*ids) ⇒ Array<Twitter::Tweet> #favorite(*ids, options) ⇒ Array<Twitter::Tweet> Also known as: fav, fave, favorite_create
Favorites the specified Tweets as the authenticating user
1400 1401 1402 1403 1404 1405 |
# File 'lib/twitter/api.rb', line 1400 def favorite(*args) = args. args.flatten.threaded_map do |id| object_from_response(Twitter::Tweet, :post, "/1.1/favorites/create.json", .merge(:id => id)) end end |
#favorites(options = {}) ⇒ Array<Twitter::Tweet> #favorites(user, options = {}) ⇒ Array<Twitter::Tweet>
Returns favorite Tweets.
1378 1379 1380 1381 1382 1383 1384 |
# File 'lib/twitter/api.rb', line 1378 def favorites(*args) = args. if user = args.pop .merge_user!(user) end collection_from_response(Twitter::Tweet, :get, "/1.1/favorites/list.json", ) end |
#follow(*args) ⇒ Array<Twitter::User> Also known as: friendship_create
Allows the authenticating user to follow the specified users, unless they are already followed
@overload(*users)
@param users [Array<Integer, String, Twitter::User>, Set<Integer, String, Twitter::User>] An array of Twitter user IDs, screen names, or objects.
@example Follow @sferik
Twitter.follow('sferik')
@overload(*users, options)
@param users [Array<Integer, String, Twitter::User>, Set<Integer, String, Twitter::User>] An array 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.
464 465 466 467 468 469 470 471 472 473 474 475 476 |
# File 'lib/twitter/api.rb', line 464 def follow(*args) = args. # Twitter always turns on notifications if the "follow" option is present, even if it's set to false # so only send follow if it's true [:follow] = true if !!.delete(:follow) existing_friends = Thread.new do friend_ids.ids end new_friends = Thread.new do users(args).map(&:id) end follow!(new_friends.value - existing_friends.value, ) end |
#follow!(*users) ⇒ Array<Twitter::User> #follow!(*users, options) ⇒ Array<Twitter::User> Also known as: friendship_create!
Allows the authenticating user to follow the specified users
494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 |
# File 'lib/twitter/api.rb', line 494 def follow!(*args) = args. # Twitter always turns on notifications if the "follow" option is present, even if it's set to false # so only send follow if it's true [:follow] = true if !!.delete(:follow) args.flatten.threaded_map do |user| begin .merge_user!(user) object_from_response(Twitter::User, :post, "/1.1/friendships/create.json", ) rescue Twitter::Error::Forbidden # This error will be raised if the user doesn't have permission to # follow list_member, for whatever reason. end end.compact end |
#follower_ids(options = {}) ⇒ Twitter::Cursor #follower_ids(user, options = {}) ⇒ Twitter::Cursor
346 347 348 |
# File 'lib/twitter/api.rb', line 346 def follower_ids(*args) ids_from_response(:get, "/1.1/followers/ids.json", args) end |
#following_followers_of(options = {}) ⇒ Object #following_followers_of(user, options = {}) ⇒ Object
Undocumented
2222 2223 2224 2225 2226 2227 |
# File 'lib/twitter/api.rb', line 2222 def following_followers_of(*args) = args. merge_default_cursor!() .merge_user!(args.pop || screen_name) cursor_from_response(:users, Twitter::User, :get, "/users/following_followers_of.json", ) end |
#friend_ids(options = {}) ⇒ Twitter::Cursor #friend_ids(user, options = {}) ⇒ Twitter::Cursor
371 372 373 |
# File 'lib/twitter/api.rb', line 371 def friend_ids(*args) ids_from_response(:get, "/1.1/friends/ids.json", args) end |
#friendship(source, target, options = {}) ⇒ Twitter::Relationship Also known as: friendship_show, relationship
Returns detailed information about the relationship between two users
439 440 441 442 443 444 445 |
# File 'lib/twitter/api.rb', line 439 def friendship(source, target, ={}) .merge_user!(source, "source") [:source_id] = .delete(:source_user_id) unless [:source_user_id].nil? .merge_user!(target, "target") [:target_id] = .delete(:target_user_id) unless [:target_user_id].nil? object_from_response(Twitter::Relationship, :get, "/1.1/friendships/show.json", ) end |
#friendship?(source, target, options = {}) ⇒ Boolean
Test for the existence of friendship between two users
389 390 391 |
# File 'lib/twitter/api.rb', line 389 def friendship?(source, target, ={}) friendship(source, target, ).source.following? end |
#friendship_update(user, options = {}) ⇒ Twitter::Relationship
Allows one to enable or disable retweets and device notifications from the specified user.
565 566 567 568 |
# File 'lib/twitter/api.rb', line 565 def friendship_update(user, ={}) .merge_user!(user) object_from_response(Twitter::Relationship, :post, "/1.1/friendships/update.json", ) end |
#friendships(*users) ⇒ Array<Twitter::User> #friendships(*users, options) ⇒ Array<Twitter::User>
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.
546 547 548 549 550 |
# File 'lib/twitter/api.rb', line 546 def friendships(*args) = args. .merge_users!(Array(args)) collection_from_response(Twitter::User, :get, "/1.1/friendships/lookup.json", ) end |
#friendships_incoming(options = {}) ⇒ Twitter::Cursor
Returns an array of numeric IDs for every user who has a pending request to follow the authenticating user
404 405 406 407 |
# File 'lib/twitter/api.rb', line 404 def friendships_incoming(={}) merge_default_cursor!() cursor_from_response(:ids, nil, :get, "/1.1/friendships/incoming.json", ) end |
#friendships_outgoing(options = {}) ⇒ Twitter::Cursor
Returns an array of numeric IDs for every protected user for whom the authenticating user has a pending follow request
420 421 422 423 |
# File 'lib/twitter/api.rb', line 420 def friendships_outgoing(={}) merge_default_cursor!() cursor_from_response(:ids, nil, :get, "/1.1/friendships/outgoing.json", ) end |
#home_timeline(options = {}) ⇒ Array<Twitter::Tweet>
This method can only return up to 800 Tweets, including retweets.
Returns the 20 most recent Tweets, including retweets if they exist, posted by the authenticating user and the users they follow
1451 1452 1453 |
# File 'lib/twitter/api.rb', line 1451 def home_timeline(={}) collection_from_response(Twitter::Tweet, :get, "/1.1/statuses/home_timeline.json", ) end |
#languages(options = {}) ⇒ Array<Twitter::Language>
Returns the list of languages supported by Twitter
691 692 693 |
# File 'lib/twitter/api.rb', line 691 def languages(={}) collection_from_response(Twitter::Language, :get, "/1.1/help/languages.json", ) end |
#list(list, options = {}) ⇒ Twitter::List #list(user, list, options = {}) ⇒ Twitter::List
Private lists will only be shown if the authenticated user owns the specified list.
Show the specified list
1202 1203 1204 |
# File 'lib/twitter/api.rb', line 1202 def list(*args) list_from_response(:get, "/1.1/lists/show.json", args) end |
#list_add_member(list, user_to_add, options = {}) ⇒ Twitter::List #list_add_member(user, list, user_to_add, options = {}) ⇒ Twitter::List
Lists are limited to having 500 members.
Add a member to a list
1083 1084 1085 |
# File 'lib/twitter/api.rb', line 1083 def list_add_member(*args) list_modify_member(:post, "/1.1/lists/members/create.json", args) end |
#list_add_members(list, users, options = {}) ⇒ Twitter::List #list_add_members(user, list, users, options = {}) ⇒ Twitter::List
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 specified members to a list
967 968 969 |
# File 'lib/twitter/api.rb', line 967 def list_add_members(*args) list_modify_members(:post, "/1.1/lists/members/create_all.json", args) end |
#list_create(name, options = {}) ⇒ Twitter::List
Accounts are limited to 20 lists.
Creates a new list for the authenticated user
1158 1159 1160 |
# File 'lib/twitter/api.rb', line 1158 def list_create(name, ={}) object_from_response(Twitter::List, :post, "/1.1/lists/create.json", .merge(:name => name)) end |
#list_destroy(list, options = {}) ⇒ Twitter::List #list_destroy(user, list, options = {}) ⇒ Twitter::List
Must be owned by the authenticated user.
Deletes the specified list
1110 1111 1112 |
# File 'lib/twitter/api.rb', line 1110 def list_destroy(*args) list_from_response(:post, "/1.1/lists/destroy.json", args) 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
1026 1027 1028 |
# File 'lib/twitter/api.rb', line 1026 def list_member?(*args) list_user?(:get, "/1.1/lists/members/show.json", args) end |
#list_members(list, options = {}) ⇒ Twitter::Cursor #list_members(user, list, options = {}) ⇒ Twitter::Cursor
Returns the members of the specified list
1054 1055 1056 |
# File 'lib/twitter/api.rb', line 1054 def list_members(*args) list_users(:get, "/1.1/lists/members.json", args) 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
781 782 783 |
# File 'lib/twitter/api.rb', line 781 def list_remove_member(*args) list_modify_member(:post, "/1.1/lists/members/destroy.json", args) end |
#list_remove_members(list, users, options = {}) ⇒ Twitter::List #list_remove_members(user, list, users, options = {}) ⇒ Twitter::List
Removes specified members from the list
999 1000 1001 |
# File 'lib/twitter/api.rb', line 999 def list_remove_members(*args) list_modify_members(:post, "/1.1/lists/members/destroy_all.json", args) end |
#list_subscribe(list, options = {}) ⇒ Twitter::List #list_subscribe(user, list, options = {}) ⇒ Twitter::List
Make the authenticated user follow the specified list
879 880 881 |
# File 'lib/twitter/api.rb', line 879 def list_subscribe(*args) list_from_response(:post, "/1.1/lists/subscribers/create.json", args) 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
909 910 911 |
# File 'lib/twitter/api.rb', line 909 def list_subscriber?(*args) list_user?(:get, "/1.1/lists/subscribers/show.json", args) end |
#list_subscribers(list, options = {}) ⇒ Twitter::Cursor #list_subscribers(user, list, options = {}) ⇒ Twitter::Cursor
Returns the subscribers of the specified list
831 832 833 |
# File 'lib/twitter/api.rb', line 831 def list_subscribers(*args) list_users(:get, "/1.1/lists/subscribers.json", args) end |
#list_timeline(list, options = {}) ⇒ Array<Twitter::Tweet> #list_timeline(user, list, options = {}) ⇒ Array<Twitter::Tweet>
Show tweet timeline for members of the specified list
749 750 751 752 753 754 |
# File 'lib/twitter/api.rb', line 749 def list_timeline(*args) = args. .merge_list!(args.pop) .merge_owner!(args.pop || screen_name) unless [:owner_id] || [:owner_screen_name] collection_from_response(Twitter::Tweet, :get, "/1.1/lists/statuses.json", ) end |
#list_unsubscribe(list, options = {}) ⇒ Twitter::List #list_unsubscribe(user, list, options = {}) ⇒ Twitter::List
Unsubscribes the authenticated user form the specified list
934 935 936 |
# File 'lib/twitter/api.rb', line 934 def list_unsubscribe(*args) list_from_response(:post, "/1.1/lists/subscribers/destroy.json", args) end |
#list_update(list, options = {}) ⇒ Twitter::List #list_update(user, list, options = {}) ⇒ Twitter::List
Updates the specified list
1140 1141 1142 |
# File 'lib/twitter/api.rb', line 1140 def list_update(*args) list_from_response(:post, "/1.1/lists/update.json", args) end |
#lists(*args) ⇒ Twitter::Cursor Also known as: lists_subscribed_to
List the lists of the specified user Returns all lists the authenticating or specified user subscribes to, including their own.
1174 1175 1176 |
# File 'lib/twitter/api.rb', line 1174 def lists(*args) lists_from_response(:get, "/1.1/lists/list.json", args) end |
#media_timeline(user, options = {}) ⇒ Array<Twitter::Tweet>
This method can only return up to the 100 most recent images.
Images will not be returned from tweets posted before January 1, 2010.
Returns the 20 most recent images posted by the specified user
1619 1620 1621 |
# File 'lib/twitter/api.rb', line 1619 def media_timeline(*args) objects_from_response(Twitter::Tweet, :get, "/1.1/statuses/media_timeline.json", args) end |
#memberships(options = {}) ⇒ Twitter::Cursor #memberships(user, options = {}) ⇒ Twitter::Cursor
List the lists the specified user has been added to
804 805 806 |
# File 'lib/twitter/api.rb', line 804 def memberships(*args) lists_from_response(:get, "/1.1/lists/memberships.json", args) end |
#mentions_timeline(options = {}) ⇒ Array<Twitter::Tweet> Also known as: mentions
This method can only return up to 800 Tweets.
Returns the 20 most recent mentions (statuses containing @username) for the authenticating user
1470 1471 1472 |
# File 'lib/twitter/api.rb', line 1470 def mentions_timeline(={}) collection_from_response(Twitter::Tweet, :get, "/1.1/statuses/mentions_timeline.json", ) end |
#oembed(id, options = {}) ⇒ Twitter::OEmbed
Returns oEmbed for a Tweet
1754 1755 1756 |
# File 'lib/twitter/api.rb', line 1754 def (id, ={}) object_from_response(Twitter::OEmbed, :get, "/1.1/statuses/oembed.json?id=#{id}", ) end |
#oembed(*ids_or_urls) ⇒ Array<Twitter::OEmbed> #oembed(*ids_or_urls, options) ⇒ Array<Twitter::OEmbed>
Returns oEmbeds for Tweets
1779 1780 1781 1782 1783 1784 |
# File 'lib/twitter/api.rb', line 1779 def (*args) = args. args.flatten.threaded_map do |id| object_from_response(Twitter::OEmbed, :get, "/1.1/statuses/oembed.json?id=#{id}", ) end end |
#phoenix_search(q, options = {}) ⇒ Array<Twitter::Tweet>
Undocumented
Returns recent Tweets related to a query with images and videos embedded
1352 1353 1354 |
# File 'lib/twitter/api.rb', line 1352 def phoenix_search(q, ={}) search_collection_from_response(:get, "/phoenix_search.phoenix", .merge(:q => q)) end |
#place(place_id, options = {}) ⇒ Twitter::Place
Returns all the information about a known place
645 646 647 |
# File 'lib/twitter/api.rb', line 645 def place(place_id, ={}) object_from_response(Twitter::Place, :get, "/1.1/geo/id/#{place_id}.json", ) end |
#place_create(options = {}) ⇒ Twitter::Place
Creates a new place at the given latitude and longitude
665 666 667 |
# File 'lib/twitter/api.rb', line 665 def place_create(={}) object_from_response(Twitter::Place, :post, "/1.1/geo/place.json", ) end |
#places_nearby(options = {}) ⇒ Array<Twitter::Place> Also known as: geo_search
Search for places that can be attached to a Twitter::API::Statuses#update
589 590 591 |
# File 'lib/twitter/api.rb', line 589 def places_nearby(={}) geo_collection_from_response(:get, "/1.1/geo/search.json", ) end |
#places_similar(options = {}) ⇒ Array<Twitter::Place>
Conceptually, you would use this method to get a list of known places to choose from first. Then, if the desired place doesn’t exist, make a request to Twitter::API::Geo#place to create a new one. The token contained in the response is the token necessary to create a new place.
Locates places near the given coordinates which are similar in name
610 611 612 |
# File 'lib/twitter/api.rb', line 610 def places_similar(={}) geo_collection_from_response(:get, "/1.1/geo/similar_places.json", ) end |
#privacy(options = {}) ⇒ String
Returns Twitter’s Privacy Policy
704 705 706 |
# File 'lib/twitter/api.rb', line 704 def privacy(={}) get("/1.1/help/privacy.json", )[:body][:privacy] end |
#report_spam(*users) ⇒ Array<Twitter::User> #report_spam(*users, options) ⇒ Array<Twitter::User>
The users specified are blocked by the authenticated user and reported as spammers
1221 1222 1223 |
# File 'lib/twitter/api.rb', line 1221 def report_spam(*args) threaded_users_from_response(:post, "/1.1/report_spam.json", args) end |
#retweet(*ids) ⇒ Array<Twitter::Tweet> #retweet(*ids, options) ⇒ Array<Twitter::Tweet>
Retweets tweets
1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 |
# File 'lib/twitter/api.rb', line 1822 def retweet(*args) = args. args.flatten.threaded_map do |id| response = post("/1.1/statuses/retweet/#{id}.json", ) retweeted_status = response.dup retweeted_status[:body] = response[:body].delete(:retweeted_status) retweeted_status[:body][:retweeted_status] = response[:body] Twitter::Tweet.from_response(retweeted_status) end end |
#retweeted_by_me(options = {}) ⇒ Array<Twitter::Tweet>
This method can only return up to 3,200 Tweets.
Returns the 20 most recent retweets posted by the authenticating user
1520 1521 1522 1523 1524 1525 1526 |
# File 'lib/twitter/api.rb', line 1520 def retweeted_by_me(={}) [:include_rts] = true count = [:count] || DEFAULT_TWEETS_PER_REQUEST collect_with_count(count) do || select_retweets(user_timeline(.merge())) end end |
#retweeted_by_user(user, options = {}) ⇒ Array<Twitter::Tweet> Also known as: retweeted_by
This method can only return up to 3,200 Tweets.
Returns the 20 most recent retweets posted by the specified user
1493 1494 1495 1496 1497 1498 1499 |
# File 'lib/twitter/api.rb', line 1493 def retweeted_by_user(user, ={}) [:include_rts] = true count = [:count] || DEFAULT_TWEETS_PER_REQUEST collect_with_count(count) do || select_retweets(user_timeline(user, .merge())) end end |
#retweeted_to_me(options = {}) ⇒ Array<Twitter::Tweet>
This method can only return up to 800 Tweets, including retweets.
Returns the 20 most recent retweets posted by users the authenticating user follow.
1546 1547 1548 1549 1550 1551 1552 |
# File 'lib/twitter/api.rb', line 1546 def retweeted_to_me(={}) [:include_rts] = true count = [:count] || DEFAULT_TWEETS_PER_REQUEST collect_with_count(count) do || select_retweets(home_timeline(.merge())) end end |
#retweeters_of(id, options = {}) ⇒ Array
Show up to 100 users who retweeted the Tweet
1637 1638 1639 1640 1641 1642 1643 |
# File 'lib/twitter/api.rb', line 1637 def retweeters_of(id, ={}) if ids_only = !!.delete(:ids_only) retweets(id, ).map(&:user).map(&:id) else retweets(id, ).map(&:user) end end |
#retweets(id, options = {}) ⇒ Array<Twitter::Tweet>
Returns up to 100 of the first retweets of a given tweet
1658 1659 1660 |
# File 'lib/twitter/api.rb', line 1658 def retweets(id, ={}) collection_from_response(Twitter::Tweet, :get, "/1.1/statuses/retweets/#{id}.json", ) end |
#retweets_of_me(options = {}) ⇒ Array<Twitter::Tweet>
This method can only return up to 3,200 Tweets.
Returns the 20 most recent tweets of the authenticated user that have been retweeted by others
1571 1572 1573 1574 1575 1576 1577 |
# File 'lib/twitter/api.rb', line 1571 def retweets_of_me(={}) [:include_rts] = false count = [:count] || DEFAULT_TWEETS_PER_REQUEST collect_with_count(count) do || user_timeline(.merge()).select{|tweet| tweet.retweet_count.to_i > 0} end end |
#reverse_geocode(options = {}) ⇒ Array<Twitter::Place>
This request is an informative call and will deliver generalized results about geography.
Searches for up to 20 places that can be used as a place_id
630 631 632 |
# File 'lib/twitter/api.rb', line 630 def reverse_geocode(={}) geo_collection_from_response(:get, "/1.1/geo/reverse_geocode.json", ) end |
#saved_search(id, options = {}) ⇒ Twitter::SavedSearch
Retrieve the data for saved searches owned by the authenticating user
1271 1272 1273 |
# File 'lib/twitter/api.rb', line 1271 def saved_search(id, ={}) object_from_response(Twitter::SavedSearch, :get, "/1.1/saved_searches/show/#{id}.json", ) end |
#saved_search_create(query, options = {}) ⇒ Twitter::SavedSearch
Creates a saved search for the authenticated user
1286 1287 1288 |
# File 'lib/twitter/api.rb', line 1286 def saved_search_create(query, ={}) object_from_response(Twitter::SavedSearch, :post, "/1.1/saved_searches/create.json", .merge(:query => query)) end |
#saved_search_destroy(*ids) ⇒ Array<Twitter::SavedSearch> #saved_search_destroy(*ids, options) ⇒ Array<Twitter::SavedSearch>
The search specified by ID must be owned by the authenticating user.
Destroys saved searches for the authenticated user
1305 1306 1307 1308 1309 1310 |
# File 'lib/twitter/api.rb', line 1305 def saved_search_destroy(*args) = args. args.flatten.threaded_map do |id| object_from_response(Twitter::SavedSearch, :post, "/1.1/saved_searches/destroy/#{id}.json", ) end end |
#saved_search(options = {}) ⇒ Array<Twitter::SavedSearch> #saved_search(*ids) ⇒ Array<Twitter::SavedSearch> #saved_search(*ids, options) ⇒ Array<Twitter::SavedSearch>
Returns The saved searches.
1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 |
# File 'lib/twitter/api.rb', line 1249 def saved_searches(*args) = args. if args.empty? collection_from_response(Twitter::SavedSearch, :get, "/1.1/saved_searches/list.json", ) else args.flatten.threaded_map do |id| object_from_response(Twitter::SavedSearch, :get, "/1.1/saved_searches/show/#{id}.json", ) end end end |
#search(q, options = {}) ⇒ Twitter::SearchResults
As of April 1st 2010, the Search API provides an option to retrieve “popular tweets” in addition to real-time search results. In an upcoming release, this will become the default and clients that don’t want to receive popular tweets in their search results will have to explicitly opt-out. See the result_type parameter below for more information.
Returns tweets that match a specified query.
1336 1337 1338 |
# File 'lib/twitter/api.rb', line 1336 def search(q, ={}) object_from_response(Twitter::SearchResults, :get, "/1.1/search/tweets.json", .merge(:q => q)) end |
#settings(options = {}) ⇒ Twitter::Settings
Updates the authenticating user’s settings. Or, if no options supplied, returns settings (including current trend, geo and sleep time information) for the authenticating user.
150 151 152 153 |
# File 'lib/twitter/api.rb', line 150 def settings(={}) request_method = .size.zero? ? :get : :post object_from_response(Twitter::Settings, request_method, "/1.1/account/settings.json", ) end |
#status(id, options = {}) ⇒ Twitter::Tweet
Returns a Tweet
1674 1675 1676 |
# File 'lib/twitter/api.rb', line 1674 def status(id, ={}) object_from_response(Twitter::Tweet, :get, "/1.1/statuses/show/#{id}.json", ) end |
#status_activity(id, options = {}) ⇒ Twitter::Tweet Also known as: tweet_activity
Undocumented
Returns activity summary for a Tweet
1708 1709 1710 1711 1712 |
# File 'lib/twitter/api.rb', line 1708 def status_activity(id, ={}) response = get("/i/statuses/#{id}/activity/summary.json", ) response[:body].merge!(:id => id) if response[:body] Twitter::Tweet.from_response(response) end |
#status_destroy(*ids) ⇒ Array<Twitter::Tweet> #status_destroy(*ids, options) ⇒ Array<Twitter::Tweet> Also known as: tweet_destroy
The authenticating user must be the author of the specified Tweets.
Destroys the specified Tweets
1802 1803 1804 |
# File 'lib/twitter/api.rb', line 1802 def status_destroy(*args) threaded_tweets_from_response(:post, "/1.1/statuses/destroy", args) end |
#statuses(*ids) ⇒ Array<Twitter::Tweet> #statuses(*ids, options) ⇒ Array<Twitter::Tweet>
Returns Tweets
1693 1694 1695 |
# File 'lib/twitter/api.rb', line 1693 def statuses(*args) threaded_tweets_from_response(:get, "/1.1/statuses/show", args) end |
#statuses_activity(*ids) ⇒ Array<Twitter::Tweet> #statuses_activity(*ids, options) ⇒ Array<Twitter::Tweet>
Undocumented
Returns activity summary for Tweets
1729 1730 1731 1732 1733 1734 |
# File 'lib/twitter/api.rb', line 1729 def statuses_activity(*args) = args. args.flatten.threaded_map do |id| status_activity(id, ) end end |
#subscriptions(options = {}) ⇒ Twitter::Cursor #subscriptions(user, options = {}) ⇒ Twitter::Cursor
List the lists the specified user follows
854 855 856 |
# File 'lib/twitter/api.rb', line 854 def subscriptions(*args) lists_from_response(:get, "/1.1/lists/subscriptions.json", args) end |
#suggest_users(slug, options = {}) ⇒ Array<Twitter::User>
Access the users in a given category of the Twitter suggested user list and return their most recent Tweet if they are not a protected user
2061 2062 2063 |
# File 'lib/twitter/api.rb', line 2061 def suggest_users(slug, ={}) collection_from_response(Twitter::User, :get, "/1.1/users/suggestions/#{slug}/members.json", ) end |
#suggestions(options = {}) ⇒ Array<Twitter::Suggestion> #suggestions(slug, options = {}) ⇒ Array<Twitter::Suggestion>
2042 2043 2044 2045 2046 2047 2048 2049 |
# File 'lib/twitter/api.rb', line 2042 def suggestions(*args) = args. if slug = args.pop object_from_response(Twitter::Suggestion, :get, "/1.1/users/suggestions/#{slug}.json", ) else collection_from_response(Twitter::Suggestion, :get, "/1.1/users/suggestions.json", ) end end |
#tos(options = {}) ⇒ String
Returns Twitter’s Terms of Service
717 718 719 |
# File 'lib/twitter/api.rb', line 717 def tos(={}) get("/1.1/help/tos.json", )[:body][:tos] end |
#trends(id = 1, options = {}) ⇒ Array<Twitter::Trend> Also known as: local_trends, trends_place
Returns the top 10 trending topics for a specific WOEID
1890 1891 1892 1893 1894 |
# File 'lib/twitter/api.rb', line 1890 def trends(id=1, ={}) [:id] = id response = get("/1.1/trends/place.json", ) collection_from_array(Twitter::Trend, response[:body].first[:trends]) end |
#trends_available(options = {}) ⇒ Array<Twitter::Place> Also known as: trend_locations
Returns the locations that Twitter has trending topic information for
1908 1909 1910 |
# File 'lib/twitter/api.rb', line 1908 def trends_available(={}) collection_from_response(Twitter::Place, :get, "/1.1/trends/available.json", ) end |
#trends_closest(options = {}) ⇒ Array<Twitter::Place>
Returns the locations that Twitter has trending topic information for, closest to a specified location.
1925 1926 1927 |
# File 'lib/twitter/api.rb', line 1925 def trends_closest(={}) collection_from_response(Twitter::Place, :get, "/1.1/trends/closest.json", ) end |
#unblock(*users) ⇒ Array<Twitter::User> #unblock(*users, options) ⇒ Array<Twitter::User>
Un-blocks the users specified by the authenticating user
2019 2020 2021 |
# File 'lib/twitter/api.rb', line 2019 def unblock(*args) threaded_users_from_response(:post, "/1.1/blocks/destroy.json", args) end |
#unfavorite(*ids) ⇒ Array<Twitter::Tweet> #unfavorite(*ids, options) ⇒ Array<Twitter::Tweet> Also known as: favorite_destroy
Un-favorites the specified Tweets as the authenticating user
1424 1425 1426 1427 1428 1429 |
# File 'lib/twitter/api.rb', line 1424 def unfavorite(*args) = args. args.flatten.threaded_map do |id| object_from_response(Twitter::Tweet, :post, "/1.1/favorites/destroy.json", .merge(:id => id)) end end |
#unfollow(*users) ⇒ Array<Twitter::User> #unfollow(*users) ⇒ Array<Twitter::User> Also known as: friendship_destroy
Allows the authenticating user to unfollow the specified users
525 526 527 |
# File 'lib/twitter/api.rb', line 525 def unfollow(*args) threaded_users_from_response(:post, "/1.1/friendships/destroy.json", args) end |
#update(status, options = {}) ⇒ Twitter::Tweet
A status update with text identical to the authenticating user’s current status will be ignored to prevent duplicates.
Updates the authenticating user’s status
1851 1852 1853 |
# File 'lib/twitter/api.rb', line 1851 def update(status, ={}) object_from_response(Twitter::Tweet, :post, "/1.1/statuses/update.json", .merge(:status => status)) end |
#update_delivery_device(device, options = {}) ⇒ Twitter::User
Sets which device Twitter delivers updates to for the authenticating user
58 59 60 |
# File 'lib/twitter/api.rb', line 58 def update_delivery_device(device, ={}) object_from_response(Twitter::User, :post, "/1.1/account/update_delivery_device.json", .merge(:device => device)) end |
#update_profile(options = {}) ⇒ Twitter::User
Only the options specified will be updated.
Sets values that users are able to set under the “Account” tab of their settings page
77 78 79 |
# File 'lib/twitter/api.rb', line 77 def update_profile(={}) object_from_response(Twitter::User, :post, "/1.1/account/update_profile.json", ) end |
#update_profile_background_image(image, options = {}) ⇒ Twitter::User
Updates the authenticating user’s profile background image
93 94 95 |
# File 'lib/twitter/api.rb', line 93 def update_profile_background_image(image, ={}) object_from_response(Twitter::User, :post, "/1.1/account/update_profile_background_image.json", .merge(:image => image)) end |
#update_profile_colors(options = {}) ⇒ Twitter::User
Sets one or more hex values that control the color scheme of the authenticating user’s profile
112 113 114 |
# File 'lib/twitter/api.rb', line 112 def update_profile_colors(={}) object_from_response(Twitter::User, :post, "/1.1/account/update_profile_colors.json", ) end |
#update_profile_image(image, options = {}) ⇒ Twitter::User
This method asynchronously processes the uploaded file before updating the user’s profile image URL. You can either update your local cache the next time you request the user’s information, or, at least 5 seconds after uploading the image, ask for the updated URL using User#profile_image_url.
Updates the authenticating user’s profile image
128 129 130 |
# File 'lib/twitter/api.rb', line 128 def update_profile_image(image, ={}) object_from_response(Twitter::User, :post, "/1.1/account/update_profile_image.json", .merge(:image => image)) end |
#update_with_media(status, media, options = {}) ⇒ Twitter::Tweet
A status update with text/media identical to the authenticating user’s current status will NOT be ignored
Updates the authenticating user’s status with media
1874 1875 1876 |
# File 'lib/twitter/api.rb', line 1874 def update_with_media(status, media, ={}) object_from_response(Twitter::Tweet, :post, "/1.1/statuses/update_with_media.json", .merge('media[]' => media, 'status' => status)) end |
#user(options = {}) ⇒ Twitter::User #user(user, options = {}) ⇒ Twitter::User
Returns The requested user.
2124 2125 2126 2127 2128 2129 2130 2131 2132 |
# File 'lib/twitter/api.rb', line 2124 def user(*args) = args. if user = args.pop .merge_user!(user) object_from_response(Twitter::User, :get, "/1.1/users/show.json", ) else verify_credentials() end end |
#user?(user, options = {}) ⇒ Boolean
Returns true if the specified user exists
2144 2145 2146 2147 2148 2149 2150 |
# File 'lib/twitter/api.rb', line 2144 def user?(user, ={}) .merge_user!(user) get("/1.1/users/show.json", ) true rescue Twitter::Error::NotFound false end |
#user_search(query, options = {}) ⇒ Array<Twitter::User>
Returns users that match the given query
2100 2101 2102 |
# File 'lib/twitter/api.rb', line 2100 def user_search(query, ={}) collection_from_response(Twitter::User, :get, "/1.1/users/search.json", .merge(:q => query)) end |
#user_timeline(user, options = {}) ⇒ Array<Twitter::Tweet>
This method can only return up to 3,200 Tweets.
Returns the 20 most recent Tweets posted by the specified user
1599 1600 1601 |
# File 'lib/twitter/api.rb', line 1599 def user_timeline(*args) objects_from_response(Twitter::Tweet, :get, "/1.1/statuses/user_timeline.json", args) end |
#users(*users) ⇒ Array<Twitter::User> #users(*users, options) ⇒ Array<Twitter::User>
Returns extended information for up to 100 users
2080 2081 2082 2083 2084 2085 |
# File 'lib/twitter/api.rb', line 2080 def users(*args) = args. args.flatten.each_slice(MAX_USERS_PER_REQUEST).threaded_map do |users| collection_from_response(Twitter::User, :post, "/1.1/users/lookup.json", .merge_users(users)) end.flatten end |
#verify_credentials(options = {}) ⇒ Twitter::User Also known as: current_user
Returns the requesting user if authentication was successful, otherwise raises Error::Unauthorized
42 43 44 |
# File 'lib/twitter/api.rb', line 42 def verify_credentials(={}) object_from_response(Twitter::User, :get, "/1.1/account/verify_credentials.json", ) end |