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.
-
#favorite!(*args) ⇒ Array<Twitter::Tweet>
(also: #fav!, #fave!, #favorite_create!)
Favorites the specified Tweets as the authenticating user and raises an error if one has already been favorited.
-
#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) ⇒ Array<Twitter::List>
(also: #lists_subscribed_to)
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.
-
#remove_profile_banner(options = {}) ⇒ nil
Removes the authenticating user’s profile banner image.
-
#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 the specified Tweets as the authenticating user.
-
#retweet!(*args) ⇒ Array<Twitter::Tweet>
Retweets the specified Tweets as the authenticating user and raises an error if one has already been retweeted.
-
#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_banner(banner, options = {}) ⇒ nil
Updates the authenticating user’s profile banner 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
207 208 209 |
# File 'lib/twitter/api.rb', line 207 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
223 224 225 |
# File 'lib/twitter/api.rb', line 223 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
2116 2117 2118 |
# File 'lib/twitter/api.rb', line 2116 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
2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 |
# File 'lib/twitter/api.rb', line 2087 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
2071 2072 2073 |
# File 'lib/twitter/api.rb', line 2071 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
2056 2057 2058 2059 |
# File 'lib/twitter/api.rb', line 2056 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
718 719 720 |
# File 'lib/twitter/api.rb', line 718 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
2287 2288 2289 |
# File 'lib/twitter/api.rb', line 2287 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
2310 2311 2312 |
# File 'lib/twitter/api.rb', line 2310 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
320 321 322 323 |
# File 'lib/twitter/api.rb', line 320 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
300 301 302 303 304 |
# File 'lib/twitter/api.rb', line 300 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
280 281 282 283 284 285 |
# File 'lib/twitter/api.rb', line 280 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.
354 355 356 357 358 359 360 361 362 363 |
# File 'lib/twitter/api.rb', line 354 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
242 243 244 |
# File 'lib/twitter/api.rb', line 242 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
261 262 263 |
# File 'lib/twitter/api.rb', line 261 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
1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 |
# File 'lib/twitter/api.rb', line 1445 def favorite(*args) = args. args.flatten.threaded_map do |id| begin object_from_response(Twitter::Tweet, :post, "/1.1/favorites/create.json", .merge(:id => id)) rescue Twitter::Error::Forbidden => error raise unless error. == Twitter::Error::AlreadyFavorited::MESSAGE end end.compact 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 and raises an error if one has already been favorited
1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 |
# File 'lib/twitter/api.rb', line 1474 def favorite!(*args) = args. args.flatten.threaded_map do |id| begin object_from_response(Twitter::Tweet, :post, "/1.1/favorites/create.json", .merge(:id => id)) rescue Twitter::Error::Forbidden => error if error. == "You have already favorited this status" raise Twitter::Error::AlreadyFavorited.new("Tweet with the ID #{id} has already been favorited by the authenticated user.") else raise end end end end |
#favorites(options = {}) ⇒ Array<Twitter::Tweet> #favorites(user, options = {}) ⇒ Array<Twitter::Tweet>
Returns favorite Tweets.
1423 1424 1425 1426 1427 1428 1429 |
# File 'lib/twitter/api.rb', line 1423 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 [Hash] A customizable set of .
@option [Boolean] :follow (false) Enable notifications for the target user.
504 505 506 507 508 509 510 511 512 513 514 515 516 |
# File 'lib/twitter/api.rb', line 504 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
534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 |
# File 'lib/twitter/api.rb', line 534 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
386 387 388 |
# File 'lib/twitter/api.rb', line 386 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
2338 2339 2340 2341 2342 2343 |
# File 'lib/twitter/api.rb', line 2338 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
411 412 413 |
# File 'lib/twitter/api.rb', line 411 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
479 480 481 482 483 484 485 |
# File 'lib/twitter/api.rb', line 479 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
429 430 431 |
# File 'lib/twitter/api.rb', line 429 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.
605 606 607 608 |
# File 'lib/twitter/api.rb', line 605 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.
586 587 588 589 590 |
# File 'lib/twitter/api.rb', line 586 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
444 445 446 447 |
# File 'lib/twitter/api.rb', line 444 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
460 461 462 463 |
# File 'lib/twitter/api.rb', line 460 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
1533 1534 1535 |
# File 'lib/twitter/api.rb', line 1533 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
731 732 733 |
# File 'lib/twitter/api.rb', line 731 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
1249 1250 1251 |
# File 'lib/twitter/api.rb', line 1249 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
1125 1126 1127 |
# File 'lib/twitter/api.rb', line 1125 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
1009 1010 1011 |
# File 'lib/twitter/api.rb', line 1009 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
1200 1201 1202 |
# File 'lib/twitter/api.rb', line 1200 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
1152 1153 1154 |
# File 'lib/twitter/api.rb', line 1152 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
1068 1069 1070 |
# File 'lib/twitter/api.rb', line 1068 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
1096 1097 1098 |
# File 'lib/twitter/api.rb', line 1096 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
821 822 823 |
# File 'lib/twitter/api.rb', line 821 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
1041 1042 1043 |
# File 'lib/twitter/api.rb', line 1041 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
921 922 923 |
# File 'lib/twitter/api.rb', line 921 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
951 952 953 |
# File 'lib/twitter/api.rb', line 951 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
873 874 875 |
# File 'lib/twitter/api.rb', line 873 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
789 790 791 792 793 794 |
# File 'lib/twitter/api.rb', line 789 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
976 977 978 |
# File 'lib/twitter/api.rb', line 976 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
1182 1183 1184 |
# File 'lib/twitter/api.rb', line 1182 def list_update(*args) list_from_response(:post, "/1.1/lists/update.json", args) end |
#memberships(options = {}) ⇒ Array<Twitter::List> #memberships(user, options = {}) ⇒ Array<Twitter::List> Also known as: lists_subscribed_to
Returns all lists the authenticating or specified user subscribes to, including their own
1221 1222 1223 |
# File 'lib/twitter/api.rb', line 1221 def lists(*args) objects_from_response(Twitter::List, :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
1696 1697 1698 |
# File 'lib/twitter/api.rb', line 1696 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
846 847 848 |
# File 'lib/twitter/api.rb', line 846 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
1552 1553 1554 |
# File 'lib/twitter/api.rb', line 1552 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
1831 1832 1833 |
# File 'lib/twitter/api.rb', line 1831 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
1856 1857 1858 1859 1860 1861 |
# File 'lib/twitter/api.rb', line 1856 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
1397 1398 1399 |
# File 'lib/twitter/api.rb', line 1397 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
685 686 687 |
# File 'lib/twitter/api.rb', line 685 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
705 706 707 |
# File 'lib/twitter/api.rb', line 705 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
629 630 631 |
# File 'lib/twitter/api.rb', line 629 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
650 651 652 |
# File 'lib/twitter/api.rb', line 650 def places_similar(={}) geo_collection_from_response(:get, "/1.1/geo/similar_places.json", ) end |
#privacy(options = {}) ⇒ String
Returns Twitter’s Privacy Policy
744 745 746 |
# File 'lib/twitter/api.rb', line 744 def privacy(={}) get("/1.1/help/privacy.json", )[:body][:privacy] end |
#remove_profile_banner(options = {}) ⇒ nil
Removes the authenticating user’s profile banner image
168 169 170 |
# File 'lib/twitter/api.rb', line 168 def (={}) post("/1.1/account/remove_profile_banner.json", )[:body] 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
1268 1269 1270 |
# File 'lib/twitter/api.rb', line 1268 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 the specified Tweets as the authenticating user
1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 |
# File 'lib/twitter/api.rb', line 1899 def retweet(*args) = args. args.flatten.threaded_map do |id| begin 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) rescue Twitter::Error::Forbidden => error raise unless error. == Twitter::Error::AlreadyRetweeted::MESSAGE end end.compact end |
#retweet(*ids) ⇒ Array<Twitter::Tweet> #retweet(*ids, options) ⇒ Array<Twitter::Tweet>
Retweets the specified Tweets as the authenticating user and raises an error if one has already been retweeted
1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 |
# File 'lib/twitter/api.rb', line 1930 def retweet!(*args) = args. args.flatten.threaded_map do |id| begin 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) rescue Twitter::Error::Forbidden => error if error. == "sharing is not permissible for this status (Share validations failed)" raise Twitter::Error::AlreadyRetweeted.new("Tweet with the ID #{id} has already been retweeted by the authenticated user.") else raise end end end.compact 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
1602 1603 1604 1605 1606 1607 1608 |
# File 'lib/twitter/api.rb', line 1602 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
1575 1576 1577 1578 1579 1580 1581 |
# File 'lib/twitter/api.rb', line 1575 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.
1628 1629 1630 1631 1632 1633 1634 |
# File 'lib/twitter/api.rb', line 1628 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
1714 1715 1716 1717 1718 1719 1720 |
# File 'lib/twitter/api.rb', line 1714 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
1735 1736 1737 |
# File 'lib/twitter/api.rb', line 1735 def retweets(id, ={}) collection_from_response(Twitter::Tweet, :get, "/1.1/statuses/retweets/#{id}.json", ) end |
#retweets_of_me(options = {}) ⇒ Array<Twitter::Tweet>
Returns the 20 most recent tweets of the authenticated user that have been retweeted by others
1652 1653 1654 |
# File 'lib/twitter/api.rb', line 1652 def retweets_of_me(={}) collection_from_response(Twitter::Tweet, :get, "/1.1/statuses/retweets_of_me.json", ) 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
670 671 672 |
# File 'lib/twitter/api.rb', line 670 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
1318 1319 1320 |
# File 'lib/twitter/api.rb', line 1318 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
1333 1334 1335 |
# File 'lib/twitter/api.rb', line 1333 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
1352 1353 1354 1355 1356 1357 |
# File 'lib/twitter/api.rb', line 1352 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.
1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 |
# File 'lib/twitter/api.rb', line 1296 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
Please note that Twitter’s search service and, by extension, the Search API is not meant to be an exhaustive source of Tweets. Not all Tweets will be indexed or made available via the search interface.
Returns tweets that match a specified query.
1381 1382 1383 |
# File 'lib/twitter/api.rb', line 1381 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.
190 191 192 193 |
# File 'lib/twitter/api.rb', line 190 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
1751 1752 1753 |
# File 'lib/twitter/api.rb', line 1751 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
1785 1786 1787 1788 1789 |
# File 'lib/twitter/api.rb', line 1785 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
1879 1880 1881 |
# File 'lib/twitter/api.rb', line 1879 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
1770 1771 1772 |
# File 'lib/twitter/api.rb', line 1770 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
1806 1807 1808 1809 1810 1811 |
# File 'lib/twitter/api.rb', line 1806 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
896 897 898 |
# File 'lib/twitter/api.rb', line 896 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
2177 2178 2179 |
# File 'lib/twitter/api.rb', line 2177 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>
2158 2159 2160 2161 2162 2163 2164 2165 |
# File 'lib/twitter/api.rb', line 2158 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
757 758 759 |
# File 'lib/twitter/api.rb', line 757 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
2006 2007 2008 2009 2010 |
# File 'lib/twitter/api.rb', line 2006 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
2024 2025 2026 |
# File 'lib/twitter/api.rb', line 2024 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.
2041 2042 2043 |
# File 'lib/twitter/api.rb', line 2041 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
2135 2136 2137 |
# File 'lib/twitter/api.rb', line 2135 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
1506 1507 1508 1509 1510 1511 |
# File 'lib/twitter/api.rb', line 1506 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
565 566 567 |
# File 'lib/twitter/api.rb', line 565 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
1967 1968 1969 |
# File 'lib/twitter/api.rb', line 1967 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
60 61 62 |
# File 'lib/twitter/api.rb', line 60 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
79 80 81 |
# File 'lib/twitter/api.rb', line 79 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
95 96 97 |
# File 'lib/twitter/api.rb', line 95 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_banner(banner, options = {}) ⇒ nil
Uploads a profile banner on behalf of the authenticating user. For best results, upload an <5MB image that is exactly 1252px by 626px. Images will be resized for a number of display options. Users with an uploaded profile banner will have a profile_banner_url node in their Users objects. More information about sizing variations can be found in User Profile Images and Banners.
Profile banner images are processed asynchronously. The profile_banner_url and its variant sizes will not necessary be available directly after upload.
Updates the authenticating user’s profile banner image
154 155 156 |
# File 'lib/twitter/api.rb', line 154 def (, ={}) post("/1.1/account/update_profile_banner.json", .merge(:banner => ))[:body] end |
#update_profile_colors(options = {}) ⇒ Twitter::User
Sets one or more hex values that control the color scheme of the authenticating user’s profile
114 115 116 |
# File 'lib/twitter/api.rb', line 114 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
Updates the authenticating user’s profile image. Note that this method expects raw multipart data, not a URL to an image.
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 GET users/show.
Updates the authenticating user’s profile image
131 132 133 |
# File 'lib/twitter/api.rb', line 131 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
1990 1991 1992 |
# File 'lib/twitter/api.rb', line 1990 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.
2240 2241 2242 2243 2244 2245 2246 2247 2248 |
# File 'lib/twitter/api.rb', line 2240 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
2260 2261 2262 2263 2264 2265 2266 |
# File 'lib/twitter/api.rb', line 2260 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
2216 2217 2218 |
# File 'lib/twitter/api.rb', line 2216 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
1676 1677 1678 |
# File 'lib/twitter/api.rb', line 1676 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
2196 2197 2198 2199 2200 2201 |
# File 'lib/twitter/api.rb', line 2196 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
44 45 46 |
# File 'lib/twitter/api.rb', line 44 def verify_credentials(={}) object_from_response(Twitter::User, :get, "/1.1/account/verify_credentials.json", ) end |