Module: Twitter::API::Tweets
Constant Summary
Constant Summary
Constants included from Utils
Instance Method Summary (collapse)
-
- (Twitter::OEmbed) oembed(id_or_url, options = {})
Returns oEmbed for a Tweet.
-
- (Array<Twitter::OEmbed>) oembeds(*args)
Returns oEmbeds for Tweets.
-
- (Array<Twitter::Tweet>) retweet(*args)
Retweets the specified Tweets as the authenticating user.
-
- (Array<Twitter::Tweet>) retweet!(*args)
Retweets the specified Tweets as the authenticating user and raises an error if one has already been retweeted.
-
- (Array) retweeters_of(id, options = {})
Show up to 100 users who retweeted the Tweet.
-
- (Array<Twitter::Tweet>) retweets(id, options = {})
Returns up to 100 of the first retweets of a given tweet.
-
- (Twitter::Tweet) status(id, options = {})
Returns a Tweet.
-
- (Array<Twitter::Tweet>) status_destroy(*args)
(also: #tweet_destroy)
Destroys the specified Tweets.
-
- (Array<Twitter::Tweet>) statuses(*args)
Returns Tweets.
-
- (Twitter::Tweet) update(status, options = {})
Updates the authenticating user's status.
-
- (Twitter::Tweet) update_with_media(status, media, options = {})
Updates the authenticating user's status with media.
Instance Method Details
- (Twitter::OEmbed) oembed(id_or_url, options = {})
Returns oEmbed for a Tweet
226 227 228 229 |
# File 'lib/twitter/api/tweets.rb', line 226 def (id_or_url, ={}) key = id_or_url.is_a?(String) && id_or_url.match(%r{^https?://}i) ? "url" : "id" object_from_response(Twitter::OEmbed, :get, "/1.1/statuses/oembed.json?#{key}=#{id_or_url}", ) end |
- (Array<Twitter::OEmbed>) oembed(*ids_or_urls) - (Array<Twitter::OEmbed>) oembed(*ids_or_urls, options)
Returns oEmbeds for Tweets
252 253 254 255 256 257 |
# File 'lib/twitter/api/tweets.rb', line 252 def (*args) arguments = Twitter::API::Arguments.new(args) arguments.flatten.threaded_map do |id_or_url| (id_or_url, arguments.) end end |
- (Array<Twitter::Tweet>) retweet(*ids) - (Array<Twitter::Tweet>) retweet(*ids, options)
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 |
- (Array<Twitter::Tweet>) retweet!(*ids) - (Array<Twitter::Tweet>) retweet!(*ids, options)
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 |
- (Array) retweeters_of(id, options = {})
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 |
- (Array<Twitter::Tweet>) retweets(id, options = {})
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 |
- (Twitter::Tweet) status(id, options = {})
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 |
- (Array<Twitter::Tweet>) status_destroy(*ids) - (Array<Twitter::Tweet>) status_destroy(*ids, options) 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 |
- (Array<Twitter::Tweet>) statuses(*ids) - (Array<Twitter::Tweet>) statuses(*ids, options)
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 |
- (Twitter::Tweet) update(status, options = {})
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 |
- (Twitter::Tweet) update_with_media(status, media, options = {})
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 |