Module: Twitter::API::Tweets
Constant Summary
Constants included from Utils
Instance Method Summary collapse
-
#oembed(id, options = {}) ⇒ Twitter::OEmbed
Returns oEmbed for a Tweet.
-
#oembeds(*args) ⇒ Array<Twitter::OEmbed>
Returns oEmbeds for Tweets.
-
#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.
-
#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.
-
#status(id, options = {}) ⇒ Twitter::Tweet
Returns a Tweet.
-
#status_destroy(*args) ⇒ Array<Twitter::Tweet>
(also: #tweet_destroy)
Destroys the specified Tweets.
-
#statuses(*args) ⇒ Array<Twitter::Tweet>
Returns Tweets.
-
#update(status, options = {}) ⇒ Twitter::Tweet
Updates the authenticating user's status.
-
#update_with_media(status, media, options = {}) ⇒ Twitter::Tweet
Updates the authenticating user's status with media.
Instance Method Details
#oembed(id, options = {}) ⇒ Twitter::OEmbed
Returns oEmbed for a Tweet
226 227 228 |
# File 'lib/twitter/api/tweets.rb', line 226 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
251 252 253 254 255 256 |
# File 'lib/twitter/api/tweets.rb', line 251 def (*args) arguments = Twitter::API::Arguments.new(args) arguments.flatten.threaded_map do |id| object_from_response(Twitter::OEmbed, :get, "/1.1/statuses/oembed.json?id=#{id}", arguments.) end end |
#retweet(*ids) ⇒ Array<Twitter::Tweet> #retweet(*ids, options) ⇒ Array<Twitter::Tweet>
Retweets the specified Tweets as the authenticating user
147 148 149 150 151 152 153 154 155 156 |
# File 'lib/twitter/api/tweets.rb', line 147 def retweet(*args) arguments = Twitter::API::Arguments.new(args) arguments.flatten.threaded_map do |id| begin post_retweet(id, arguments.) 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
174 175 176 177 178 179 180 181 182 183 |
# File 'lib/twitter/api/tweets.rb', line 174 def retweet!(*args) arguments = Twitter::API::Arguments.new(args) arguments.flatten.threaded_map do |id| begin post_retweet(id, arguments.) rescue Twitter::Error::Forbidden => error handle_forbidden_error(Twitter::Error::AlreadyRetweeted, error) end end.compact end |
#retweeters_of(id, options = {}) ⇒ Array
Show up to 100 users who retweeted the Tweet
44 45 46 47 48 49 50 51 52 |
# File 'lib/twitter/api/tweets.rb', line 44 def retweeters_of(id, ={}) ids_only = !!.delete(:ids_only) retweeters = retweets(id, ).map(&:user) if ids_only retweeters.map(&:id) else retweeters end end |
#retweets(id, options = {}) ⇒ Array<Twitter::Tweet>
Returns up to 100 of the first retweets of a given tweet
26 27 28 |
# File 'lib/twitter/api/tweets.rb', line 26 def retweets(id, ={}) objects_from_response(Twitter::Tweet, :get, "/1.1/statuses/retweets/#{id}.json", ) end |
#status(id, options = {}) ⇒ Twitter::Tweet
Returns a Tweet
66 67 68 |
# File 'lib/twitter/api/tweets.rb', line 66 def status(id, ={}) object_from_response(Twitter::Tweet, :get, "/1.1/statuses/show/#{id}.json", ) 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
105 106 107 |
# File 'lib/twitter/api/tweets.rb', line 105 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
85 86 87 |
# File 'lib/twitter/api/tweets.rb', line 85 def statuses(*args) threaded_tweets_from_response(:get, "/1.1/statuses/show", 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
128 129 130 |
# File 'lib/twitter/api/tweets.rb', line 128 def update(status, ={}) object_from_response(Twitter::Tweet, :post, "/1.1/statuses/update.json", .merge(:status => status)) 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
204 205 206 |
# File 'lib/twitter/api/tweets.rb', line 204 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 |