twitter 4.8.1 → 5.0.0.rc.1
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/CHANGELOG.md +30 -0
- data/LICENSE.md +1 -1
- data/README.md +386 -266
- data/lib/twitter.rb +4 -39
- data/lib/twitter/arguments.rb +11 -0
- data/lib/twitter/base.rb +89 -68
- data/lib/twitter/client.rb +69 -110
- data/lib/twitter/configuration.rb +7 -3
- data/lib/twitter/creatable.rb +2 -4
- data/lib/twitter/cursor.rb +50 -42
- data/lib/twitter/direct_message.rb +2 -11
- data/lib/twitter/entity/uri.rb +13 -0
- data/lib/twitter/enumerable.rb +15 -0
- data/lib/twitter/error.rb +55 -7
- data/lib/twitter/error/already_favorited.rb +1 -1
- data/lib/twitter/error/already_posted.rb +10 -0
- data/lib/twitter/error/already_retweeted.rb +1 -1
- data/lib/twitter/error/bad_gateway.rb +2 -3
- data/lib/twitter/error/bad_request.rb +2 -2
- data/lib/twitter/error/forbidden.rb +2 -2
- data/lib/twitter/error/gateway_timeout.rb +2 -3
- data/lib/twitter/error/internal_server_error.rb +2 -3
- data/lib/twitter/error/not_acceptable.rb +2 -2
- data/lib/twitter/error/not_found.rb +2 -2
- data/lib/twitter/error/service_unavailable.rb +2 -3
- data/lib/twitter/error/too_many_requests.rb +2 -2
- data/lib/twitter/error/unauthorized.rb +2 -2
- data/lib/twitter/error/unprocessable_entity.rb +2 -2
- data/lib/twitter/factory.rb +2 -8
- data/lib/twitter/geo_factory.rb +2 -2
- data/lib/twitter/geo_results.rb +36 -0
- data/lib/twitter/identity.rb +0 -22
- data/lib/twitter/list.rb +18 -4
- data/lib/twitter/media/photo.rb +3 -3
- data/lib/twitter/media_factory.rb +2 -2
- data/lib/twitter/null_object.rb +24 -0
- data/lib/twitter/oembed.rb +3 -2
- data/lib/twitter/place.rb +15 -9
- data/lib/twitter/profile_banner.rb +5 -3
- data/lib/twitter/rate_limit.rb +1 -17
- data/lib/twitter/relationship.rb +2 -10
- data/lib/twitter/rest/api/direct_messages.rb +135 -0
- data/lib/twitter/rest/api/favorites.rb +120 -0
- data/lib/twitter/rest/api/friends_and_followers.rb +290 -0
- data/lib/twitter/rest/api/help.rb +58 -0
- data/lib/twitter/rest/api/lists.rb +491 -0
- data/lib/twitter/rest/api/oauth.rb +45 -0
- data/lib/twitter/rest/api/places_and_geo.rb +104 -0
- data/lib/twitter/rest/api/saved_searches.rb +91 -0
- data/lib/twitter/rest/api/search.rb +37 -0
- data/lib/twitter/rest/api/spam_reporting.rb +29 -0
- data/lib/twitter/rest/api/suggested_users.rb +51 -0
- data/lib/twitter/rest/api/timelines.rb +202 -0
- data/lib/twitter/rest/api/trends.rb +58 -0
- data/lib/twitter/rest/api/tweets.rb +293 -0
- data/lib/twitter/rest/api/undocumented.rb +52 -0
- data/lib/twitter/rest/api/users.rb +383 -0
- data/lib/twitter/rest/api/utils.rb +219 -0
- data/lib/twitter/rest/client.rb +193 -0
- data/lib/twitter/rest/request/multipart_with_file.rb +36 -0
- data/lib/twitter/rest/response/parse_json.rb +27 -0
- data/lib/twitter/{response → rest/response}/raise_error.rb +8 -11
- data/lib/twitter/search_results.rb +33 -21
- data/lib/twitter/settings.rb +1 -6
- data/lib/twitter/size.rb +1 -1
- data/lib/twitter/streaming/client.rb +77 -0
- data/lib/twitter/streaming/connection.rb +22 -0
- data/lib/twitter/streaming/response.rb +30 -0
- data/lib/twitter/suggestion.rb +4 -2
- data/lib/twitter/token.rb +8 -0
- data/lib/twitter/trend.rb +2 -1
- data/lib/twitter/trend_results.rb +59 -0
- data/lib/twitter/tweet.rb +41 -85
- data/lib/twitter/user.rb +51 -41
- data/lib/twitter/version.rb +4 -4
- data/spec/fixtures/already_posted.json +1 -0
- data/spec/fixtures/ids_list.json +1 -1
- data/spec/fixtures/ids_list2.json +1 -1
- data/spec/fixtures/search.json +1 -1
- data/spec/fixtures/search_malformed.json +1 -1
- data/spec/fixtures/track_streaming.json +3 -0
- data/spec/helper.rb +8 -13
- data/spec/twitter/base_spec.rb +25 -99
- data/spec/twitter/configuration_spec.rb +1 -1
- data/spec/twitter/cursor_spec.rb +13 -31
- data/spec/twitter/direct_message_spec.rb +41 -8
- data/spec/twitter/entity/uri_spec.rb +74 -0
- data/spec/twitter/error_spec.rb +59 -11
- data/spec/twitter/geo/point_spec.rb +1 -1
- data/spec/twitter/geo_factory_spec.rb +3 -3
- data/spec/twitter/geo_results_spec.rb +35 -0
- data/spec/twitter/identifiable_spec.rb +0 -21
- data/spec/twitter/list_spec.rb +51 -8
- data/spec/twitter/media/photo_spec.rb +118 -3
- data/spec/twitter/media_factory_spec.rb +2 -2
- data/spec/twitter/null_object_spec.rb +26 -0
- data/spec/twitter/oembed_spec.rb +69 -45
- data/spec/twitter/place_spec.rb +68 -12
- data/spec/twitter/profile_banner_spec.rb +1 -1
- data/spec/twitter/rate_limit_spec.rb +12 -12
- data/spec/twitter/relationship_spec.rb +31 -9
- data/spec/twitter/{api → rest/api}/direct_messages_spec.rb +22 -9
- data/spec/twitter/{api → rest/api}/favorites_spec.rb +80 -7
- data/spec/twitter/{api → rest/api}/friends_and_followers_spec.rb +104 -65
- data/spec/twitter/{api → rest/api}/geo_spec.rb +10 -10
- data/spec/twitter/{api → rest/api}/help_spec.rb +6 -6
- data/spec/twitter/{api → rest/api}/lists_spec.rb +77 -56
- data/spec/twitter/{api → rest/api}/oauth_spec.rb +6 -6
- data/spec/twitter/{api → rest/api}/saved_searches_spec.rb +7 -7
- data/spec/twitter/{api → rest/api}/search_spec.rb +8 -9
- data/spec/twitter/{api → rest/api}/spam_reporting_spec.rb +3 -3
- data/spec/twitter/{api → rest/api}/suggested_users_spec.rb +5 -5
- data/spec/twitter/{api → rest/api}/timelines_spec.rb +9 -9
- data/spec/twitter/{api → rest/api}/trends_spec.rb +6 -6
- data/spec/twitter/rest/api/tweets_spec.rb +503 -0
- data/spec/twitter/{api → rest/api}/undocumented_spec.rb +19 -45
- data/spec/twitter/{api → rest/api}/users_spec.rb +60 -35
- data/spec/twitter/rest/client_spec.rb +193 -0
- data/spec/twitter/saved_search_spec.rb +11 -0
- data/spec/twitter/search_results_spec.rb +29 -42
- data/spec/twitter/settings_spec.rb +17 -6
- data/spec/twitter/streaming/client_spec.rb +75 -0
- data/spec/twitter/token_spec.rb +16 -0
- data/spec/twitter/trend_results_spec.rb +89 -0
- data/spec/twitter/trend_spec.rb +23 -0
- data/spec/twitter/tweet_spec.rb +122 -115
- data/spec/twitter/user_spec.rb +136 -77
- data/spec/twitter_spec.rb +0 -119
- data/twitter.gemspec +8 -5
- metadata +148 -141
- metadata.gz.sig +0 -0
- data/lib/twitter/action/favorite.rb +0 -19
- data/lib/twitter/action/follow.rb +0 -30
- data/lib/twitter/action/list_member_added.rb +0 -39
- data/lib/twitter/action/mention.rb +0 -46
- data/lib/twitter/action/reply.rb +0 -27
- data/lib/twitter/action/retweet.rb +0 -27
- data/lib/twitter/action/tweet.rb +0 -20
- data/lib/twitter/action_factory.rb +0 -22
- data/lib/twitter/api/arguments.rb +0 -13
- data/lib/twitter/api/direct_messages.rb +0 -148
- data/lib/twitter/api/favorites.rb +0 -126
- data/lib/twitter/api/friends_and_followers.rb +0 -334
- data/lib/twitter/api/help.rb +0 -64
- data/lib/twitter/api/lists.rb +0 -618
- data/lib/twitter/api/oauth.rb +0 -44
- data/lib/twitter/api/places_and_geo.rb +0 -121
- data/lib/twitter/api/saved_searches.rb +0 -99
- data/lib/twitter/api/search.rb +0 -37
- data/lib/twitter/api/spam_reporting.rb +0 -30
- data/lib/twitter/api/suggested_users.rb +0 -55
- data/lib/twitter/api/timelines.rb +0 -214
- data/lib/twitter/api/trends.rb +0 -63
- data/lib/twitter/api/tweets.rb +0 -304
- data/lib/twitter/api/undocumented.rb +0 -97
- data/lib/twitter/api/users.rb +0 -439
- data/lib/twitter/api/utils.rb +0 -187
- data/lib/twitter/configurable.rb +0 -96
- data/lib/twitter/default.rb +0 -102
- data/lib/twitter/entity/url.rb +0 -9
- data/lib/twitter/error/client_error.rb +0 -35
- data/lib/twitter/error/decode_error.rb +0 -9
- data/lib/twitter/error/identity_map_key_error.rb +0 -9
- data/lib/twitter/error/server_error.rb +0 -28
- data/lib/twitter/exceptable.rb +0 -36
- data/lib/twitter/identity_map.rb +0 -22
- data/lib/twitter/request/multipart_with_file.rb +0 -34
- data/lib/twitter/response/parse_json.rb +0 -25
- data/spec/fixtures/about_me.json +0 -1
- data/spec/fixtures/activity_summary.json +0 -1
- data/spec/fixtures/bad_gateway.json +0 -1
- data/spec/fixtures/bad_request.json +0 -1
- data/spec/fixtures/by_friends.json +0 -1
- data/spec/fixtures/end_session.json +0 -1
- data/spec/fixtures/forbidden.json +0 -1
- data/spec/fixtures/internal_server_error.json +0 -1
- data/spec/fixtures/not_acceptable.json +0 -1
- data/spec/fixtures/phoenix_search.phoenix +0 -1
- data/spec/fixtures/resolve.json +0 -1
- data/spec/fixtures/service_unavailable.json +0 -1
- data/spec/fixtures/totals.json +0 -1
- data/spec/fixtures/trends.json +0 -1
- data/spec/fixtures/unauthorized.json +0 -1
- data/spec/fixtures/video_facets.json +0 -1
- data/spec/twitter/action/favorite_spec.rb +0 -29
- data/spec/twitter/action/follow_spec.rb +0 -29
- data/spec/twitter/action/list_member_added_spec.rb +0 -41
- data/spec/twitter/action/mention_spec.rb +0 -52
- data/spec/twitter/action/reply_spec.rb +0 -41
- data/spec/twitter/action/retweet_spec.rb +0 -41
- data/spec/twitter/action_factory_spec.rb +0 -35
- data/spec/twitter/action_spec.rb +0 -16
- data/spec/twitter/api/tweets_spec.rb +0 -285
- data/spec/twitter/client_spec.rb +0 -223
- data/spec/twitter/error/client_error_spec.rb +0 -23
- data/spec/twitter/error/server_error_spec.rb +0 -20
data/lib/twitter/api/trends.rb
DELETED
@@ -1,63 +0,0 @@
|
|
1
|
-
require 'twitter/api/utils'
|
2
|
-
require 'twitter/place'
|
3
|
-
require 'twitter/trend'
|
4
|
-
|
5
|
-
module Twitter
|
6
|
-
module API
|
7
|
-
module Trends
|
8
|
-
include Twitter::API::Utils
|
9
|
-
|
10
|
-
# Returns the top 10 trending topics for a specific WOEID
|
11
|
-
#
|
12
|
-
# @see https://dev.twitter.com/docs/api/1.1/get/trends/place
|
13
|
-
# @rate_limited Yes
|
14
|
-
# @authentication Requires user context
|
15
|
-
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
16
|
-
# @param id [Integer] The {https://developer.yahoo.com/geo/geoplanet Yahoo! Where On Earth ID} of the location to return trending information for. WOEIDs can be retrieved by calling {Twitter::API::Trends#trend_locations}. Global information is available by using 1 as the WOEID.
|
17
|
-
# @param options [Hash] A customizable set of options.
|
18
|
-
# @option options [String] :exclude Setting this equal to 'hashtags' will remove all hashtags from the trends list.
|
19
|
-
# @return [Array<Twitter::Trend>]
|
20
|
-
# @example Return the top 10 trending topics for San Francisco
|
21
|
-
# Twitter.trends(2487956)
|
22
|
-
def trends(id=1, options={})
|
23
|
-
options[:id] = id
|
24
|
-
response = get("/1.1/trends/place.json", options)
|
25
|
-
objects_from_array(Twitter::Trend, response[:body].first[:trends])
|
26
|
-
end
|
27
|
-
alias local_trends trends
|
28
|
-
alias trends_place trends
|
29
|
-
|
30
|
-
# Returns the locations that Twitter has trending topic information for
|
31
|
-
#
|
32
|
-
# @see https://dev.twitter.com/docs/api/1.1/get/trends/available
|
33
|
-
# @rate_limited Yes
|
34
|
-
# @authentication Requires user context
|
35
|
-
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
36
|
-
# @param options [Hash] A customizable set of options.
|
37
|
-
# @return [Array<Twitter::Place>]
|
38
|
-
# @example Return the locations that Twitter has trending topic information for
|
39
|
-
# Twitter.trends_available
|
40
|
-
def trends_available(options={})
|
41
|
-
objects_from_response(Twitter::Place, :get, "/1.1/trends/available.json", options)
|
42
|
-
end
|
43
|
-
alias trend_locations trends_available
|
44
|
-
|
45
|
-
# Returns the locations that Twitter has trending topic information for, closest to a specified location.
|
46
|
-
#
|
47
|
-
# @see https://dev.twitter.com/docs/api/1.1/get/trends/closest
|
48
|
-
# @rate_limited Yes
|
49
|
-
# @authentication Requires user context
|
50
|
-
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
51
|
-
# @param options [Hash] A customizable set of options.
|
52
|
-
# @option options [Float] :lat If provided with a :long option the available trend locations will be sorted by distance, nearest to furthest, to the co-ordinate pair. The valid ranges for latitude are -90.0 to +90.0 (North is positive) inclusive.
|
53
|
-
# @option options [Float] :long If provided with a :lat option the available trend locations will be sorted by distance, nearest to furthest, to the co-ordinate pair. The valid ranges for longitude are -180.0 to +180.0 (East is positive) inclusive.
|
54
|
-
# @return [Array<Twitter::Place>]
|
55
|
-
# @example Return the locations that Twitter has trending topic information for
|
56
|
-
# Twitter.trends_closest
|
57
|
-
def trends_closest(options={})
|
58
|
-
objects_from_response(Twitter::Place, :get, "/1.1/trends/closest.json", options)
|
59
|
-
end
|
60
|
-
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
data/lib/twitter/api/tweets.rb
DELETED
@@ -1,304 +0,0 @@
|
|
1
|
-
require 'twitter/api/arguments'
|
2
|
-
require 'twitter/api/utils'
|
3
|
-
require 'twitter/error/already_retweeted'
|
4
|
-
require 'twitter/error/forbidden'
|
5
|
-
require 'twitter/oembed'
|
6
|
-
require 'twitter/tweet'
|
7
|
-
|
8
|
-
module Twitter
|
9
|
-
module API
|
10
|
-
module Tweets
|
11
|
-
include Twitter::API::Utils
|
12
|
-
|
13
|
-
# Returns up to 100 of the first retweets of a given tweet
|
14
|
-
#
|
15
|
-
# @see https://dev.twitter.com/docs/api/1.1/get/statuses/retweets/:id
|
16
|
-
# @rate_limited Yes
|
17
|
-
# @authentication Requires user context
|
18
|
-
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
19
|
-
# @return [Array<Twitter::Tweet>]
|
20
|
-
# @param id [Integer] The numerical ID of the desired Tweet.
|
21
|
-
# @param options [Hash] A customizable set of options.
|
22
|
-
# @option options [Integer] :count Specifies the number of records to retrieve. Must be less than or equal to 100.
|
23
|
-
# @option options [Boolean, String, Integer] :trim_user Each tweet returned in a timeline will include a user object with only the author's numerical ID when set to true, 't' or 1.
|
24
|
-
# @example Return up to 100 of the first retweets of the Tweet with the ID 28561922516
|
25
|
-
# Twitter.retweets(28561922516)
|
26
|
-
def retweets(id, options={})
|
27
|
-
objects_from_response(Twitter::Tweet, :get, "/1.1/statuses/retweets/#{id}.json", options)
|
28
|
-
end
|
29
|
-
|
30
|
-
# Show up to 100 users who retweeted the Tweet
|
31
|
-
#
|
32
|
-
# @see https://dev.twitter.com/docs/api/1.1/get/statuses/retweets/:id
|
33
|
-
# @rate_limited Yes
|
34
|
-
# @authentication Requires user context
|
35
|
-
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
36
|
-
# @return [Array]
|
37
|
-
# @param id [Integer] The numerical ID of the desired Tweet.
|
38
|
-
# @param options [Hash] A customizable set of options.
|
39
|
-
# @option options [Integer] :count Specifies the number of records to retrieve. Must be less than or equal to 100.
|
40
|
-
# @option options [Boolean, String, Integer] :trim_user Each tweet returned in a timeline will include a user object with only the author's numerical ID when set to true, 't' or 1.
|
41
|
-
# @option options [Boolean] :ids_only ('false') Only return user ids instead of full user objects.
|
42
|
-
# @example Show up to 100 users who retweeted the Tweet with the ID 28561922516
|
43
|
-
# Twitter.retweeters_of(28561922516)
|
44
|
-
def retweeters_of(id, options={})
|
45
|
-
ids_only = !!options.delete(:ids_only)
|
46
|
-
retweeters = retweets(id, options).map(&:user)
|
47
|
-
if ids_only
|
48
|
-
retweeters.map(&:id)
|
49
|
-
else
|
50
|
-
retweeters
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
# Returns a Tweet
|
55
|
-
#
|
56
|
-
# @see https://dev.twitter.com/docs/api/1.1/get/statuses/show/:id
|
57
|
-
# @rate_limited Yes
|
58
|
-
# @authentication Requires user context
|
59
|
-
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
60
|
-
# @return [Twitter::Tweet] The requested Tweet.
|
61
|
-
# @param id [Integer] A Tweet ID.
|
62
|
-
# @param options [Hash] A customizable set of options.
|
63
|
-
# @option options [Boolean, String, Integer] :trim_user Each tweet returned in a timeline will include a user object with only the author's numerical ID when set to true, 't' or 1.
|
64
|
-
# @example Return the Tweet with the ID 25938088801
|
65
|
-
# Twitter.status(25938088801)
|
66
|
-
def status(id, options={})
|
67
|
-
object_from_response(Twitter::Tweet, :get, "/1.1/statuses/show/#{id}.json", options)
|
68
|
-
end
|
69
|
-
|
70
|
-
# Returns Tweets
|
71
|
-
#
|
72
|
-
# @see https://dev.twitter.com/docs/api/1.1/get/statuses/show/:id
|
73
|
-
# @rate_limited Yes
|
74
|
-
# @authentication Requires user context
|
75
|
-
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
76
|
-
# @return [Array<Twitter::Tweet>] The requested Tweets.
|
77
|
-
# @overload statuses(*ids)
|
78
|
-
# @param ids [Array<Integer>, Set<Integer>] An array of Tweet IDs.
|
79
|
-
# @example Return the Tweet with the ID 25938088801
|
80
|
-
# Twitter.statuses(25938088801)
|
81
|
-
# @overload statuses(*ids, options)
|
82
|
-
# @param ids [Array<Integer>, Set<Integer>] An array of Tweet IDs.
|
83
|
-
# @param options [Hash] A customizable set of options.
|
84
|
-
# @option options [Boolean, String, Integer] :trim_user Each tweet returned in a timeline will include a user object with only the author's numerical ID when set to true, 't' or 1.
|
85
|
-
def statuses(*args)
|
86
|
-
threaded_tweets_from_response(:get, "/1.1/statuses/show", args)
|
87
|
-
end
|
88
|
-
|
89
|
-
# Destroys the specified Tweets
|
90
|
-
#
|
91
|
-
# @see https://dev.twitter.com/docs/api/1.1/post/statuses/destroy/:id
|
92
|
-
# @note The authenticating user must be the author of the specified Tweets.
|
93
|
-
# @rate_limited No
|
94
|
-
# @authentication Requires user context
|
95
|
-
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
96
|
-
# @return [Array<Twitter::Tweet>] The deleted Tweets.
|
97
|
-
# @overload status_destroy(*ids)
|
98
|
-
# @param ids [Array<Integer>, Set<Integer>] An array of Tweet IDs.
|
99
|
-
# @example Destroy the Tweet with the ID 25938088801
|
100
|
-
# Twitter.status_destroy(25938088801)
|
101
|
-
# @overload status_destroy(*ids, options)
|
102
|
-
# @param ids [Array<Integer>, Set<Integer>] An array of Tweet IDs.
|
103
|
-
# @param options [Hash] A customizable set of options.
|
104
|
-
# @option options [Boolean, String, Integer] :trim_user Each tweet returned in a timeline will include a user object with only the author's numerical ID when set to true, 't' or 1.
|
105
|
-
def status_destroy(*args)
|
106
|
-
threaded_tweets_from_response(:post, "/1.1/statuses/destroy", args)
|
107
|
-
end
|
108
|
-
alias tweet_destroy status_destroy
|
109
|
-
|
110
|
-
# Updates the authenticating user's status
|
111
|
-
#
|
112
|
-
# @see https://dev.twitter.com/docs/api/1.1/post/statuses/update
|
113
|
-
# @note A status update with text identical to the authenticating user's current status will be ignored to prevent duplicates.
|
114
|
-
# @rate_limited No
|
115
|
-
# @authentication Requires user context
|
116
|
-
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
117
|
-
# @return [Twitter::Tweet] The created Tweet.
|
118
|
-
# @param status [String] The text of your status update, up to 140 characters.
|
119
|
-
# @param options [Hash] A customizable set of options.
|
120
|
-
# @option options [Integer] :in_reply_to_status_id The ID of an existing status that the update is in reply to.
|
121
|
-
# @option options [Float] :lat The latitude of the location this tweet refers to. This option will be ignored unless it is inside the range -90.0 to +90.0 (North is positive) inclusive. It will also be ignored if there isn't a corresponding :long option.
|
122
|
-
# @option options [Float] :long The longitude of the location this tweet refers to. The valid ranges for longitude is -180.0 to +180.0 (East is positive) inclusive. This option will be ignored if outside that range, if it is not a number, if geo_enabled is disabled, or if there not a corresponding :lat option.
|
123
|
-
# @option options [String] :place_id A place in the world. These IDs can be retrieved from {Twitter::API::PlacesAndGeo#reverse_geocode}.
|
124
|
-
# @option options [String] :display_coordinates Whether or not to put a pin on the exact coordinates a tweet has been sent from.
|
125
|
-
# @option options [Boolean, String, Integer] :trim_user Each tweet returned in a timeline will include a user object with only the author's numerical ID when set to true, 't' or 1.
|
126
|
-
# @example Update the authenticating user's status
|
127
|
-
# Twitter.update("I'm tweeting with @gem!")
|
128
|
-
def update(status, options={})
|
129
|
-
object_from_response(Twitter::Tweet, :post, "/1.1/statuses/update.json", options.merge(:status => status))
|
130
|
-
end
|
131
|
-
|
132
|
-
# Retweets the specified Tweets as the authenticating user
|
133
|
-
#
|
134
|
-
# @see https://dev.twitter.com/docs/api/1.1/post/statuses/retweet/:id
|
135
|
-
# @rate_limited Yes
|
136
|
-
# @authentication Requires user context
|
137
|
-
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
138
|
-
# @return [Array<Twitter::Tweet>] The original tweets with retweet details embedded.
|
139
|
-
# @overload retweet(*ids)
|
140
|
-
# @param ids [Array<Integer>, Set<Integer>] An array of Tweet IDs.
|
141
|
-
# @example Retweet the Tweet with the ID 28561922516
|
142
|
-
# Twitter.retweet(28561922516)
|
143
|
-
# @overload retweet(*ids, options)
|
144
|
-
# @param ids [Array<Integer>, Set<Integer>] An array of Tweet IDs.
|
145
|
-
# @param options [Hash] A customizable set of options.
|
146
|
-
# @option options [Boolean, String, Integer] :trim_user Each tweet returned in a timeline will include a user object with only the author's numerical ID when set to true, 't' or 1.
|
147
|
-
def retweet(*args)
|
148
|
-
arguments = Twitter::API::Arguments.new(args)
|
149
|
-
arguments.flatten.threaded_map do |id|
|
150
|
-
begin
|
151
|
-
post_retweet(id, arguments.options)
|
152
|
-
rescue Twitter::Error::Forbidden => error
|
153
|
-
raise unless error.message == Twitter::Error::AlreadyRetweeted::MESSAGE
|
154
|
-
end
|
155
|
-
end.compact
|
156
|
-
end
|
157
|
-
|
158
|
-
# Retweets the specified Tweets as the authenticating user and raises an error if one has already been retweeted
|
159
|
-
#
|
160
|
-
# @see https://dev.twitter.com/docs/api/1.1/post/statuses/retweet/:id
|
161
|
-
# @rate_limited Yes
|
162
|
-
# @authentication Requires user context
|
163
|
-
# @raise [Twitter::Error::AlreadyRetweeted] Error raised when tweet has already been retweeted.
|
164
|
-
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
165
|
-
# @return [Array<Twitter::Tweet>] The original tweets with retweet details embedded.
|
166
|
-
# @overload retweet!(*ids)
|
167
|
-
# @param ids [Array<Integer>, Set<Integer>] An array of Tweet IDs.
|
168
|
-
# @example Retweet the Tweet with the ID 28561922516
|
169
|
-
# Twitter.retweet!(28561922516)
|
170
|
-
# @overload retweet!(*ids, options)
|
171
|
-
# @param ids [Array<Integer>, Set<Integer>] An array of Tweet IDs.
|
172
|
-
# @param options [Hash] A customizable set of options.
|
173
|
-
# @option options [Boolean, String, Integer] :trim_user Each tweet returned in a timeline will include a user object with only the author's numerical ID when set to true, 't' or 1.
|
174
|
-
def retweet!(*args)
|
175
|
-
arguments = Twitter::API::Arguments.new(args)
|
176
|
-
arguments.flatten.threaded_map do |id|
|
177
|
-
begin
|
178
|
-
post_retweet(id, arguments.options)
|
179
|
-
rescue Twitter::Error::Forbidden => error
|
180
|
-
handle_forbidden_error(Twitter::Error::AlreadyRetweeted, error)
|
181
|
-
end
|
182
|
-
end.compact
|
183
|
-
end
|
184
|
-
|
185
|
-
# Updates the authenticating user's status with media
|
186
|
-
#
|
187
|
-
# @see https://dev.twitter.com/docs/api/1.1/post/statuses/update_with_media
|
188
|
-
# @note A status update with text/media identical to the authenticating user's current status will NOT be ignored
|
189
|
-
# @rate_limited No
|
190
|
-
# @authentication Requires user context
|
191
|
-
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
192
|
-
# @return [Twitter::Tweet] The created Tweet.
|
193
|
-
# @param status [String] The text of your status update, up to 140 characters.
|
194
|
-
# @param media [File, Hash] A File object with your picture (PNG, JPEG or GIF)
|
195
|
-
# @param options [Hash] A customizable set of options.
|
196
|
-
# @option options [Integer] :in_reply_to_status_id The ID of an existing Tweet that the update is in reply to.
|
197
|
-
# @option options [Float] :lat The latitude of the location this tweet refers to. This option will be ignored unless it is inside the range -90.0 to +90.0 (North is positive) inclusive. It will also be ignored if there isn't a corresponding :long option.
|
198
|
-
# @option options [Float] :long The longitude of the location this tweet refers to. The valid ranges for longitude is -180.0 to +180.0 (East is positive) inclusive. This option will be ignored if outside that range, if it is not a number, if geo_enabled is disabled, or if there not a corresponding :lat option.
|
199
|
-
# @option options [String] :place_id A place in the world. These IDs can be retrieved from {Twitter::API::PlacesAndGeo#reverse_geocode}.
|
200
|
-
# @option options [String] :display_coordinates Whether or not to put a pin on the exact coordinates a tweet has been sent from.
|
201
|
-
# @option options [Boolean, String, Integer] :trim_user Each tweet returned in a timeline will include a user object with only the author's numerical ID when set to true, 't' or 1.
|
202
|
-
# @example Update the authenticating user's status
|
203
|
-
# Twitter.update_with_media("I'm tweeting with @gem!", File.new('my_awesome_pic.jpeg'))
|
204
|
-
def update_with_media(status, media, options={})
|
205
|
-
object_from_response(Twitter::Tweet, :post, "/1.1/statuses/update_with_media.json", options.merge('media[]' => media, 'status' => status))
|
206
|
-
end
|
207
|
-
|
208
|
-
# Returns oEmbed for a Tweet
|
209
|
-
#
|
210
|
-
# @see https://dev.twitter.com/docs/api/1.1/get/statuses/oembed
|
211
|
-
# @rate_limited Yes
|
212
|
-
# @authentication Requires user context
|
213
|
-
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
214
|
-
# @return [Twitter::OEmbed] OEmbed for the requested Tweet.
|
215
|
-
# @param id_or_url [Integer, String] A Tweet ID or URL.
|
216
|
-
# @param options [Hash] A customizable set of options.
|
217
|
-
# @option options [Integer] :maxwidth The maximum width in pixels that the embed should be rendered at. This value is constrained to be between 250 and 550 pixels.
|
218
|
-
# @option options [Boolean, String, Integer] :hide_media Specifies whether the embedded Tweet should automatically expand images which were uploaded via {https://dev.twitter.com/docs/api/1.1/post/statuses/update_with_media POST statuses/update_with_media}. When set to either true, t or 1 images will not be expanded. Defaults to false.
|
219
|
-
# @option options [Boolean, String, Integer] :hide_thread Specifies whether the embedded Tweet should automatically show the original message in the case that the embedded Tweet is a reply. When set to either true, t or 1 the original Tweet will not be shown. Defaults to false.
|
220
|
-
# @option options [Boolean, String, Integer] :omit_script Specifies whether the embedded Tweet HTML should include a `<script>` element pointing to widgets.js. In cases where a page already includes widgets.js, setting this value to true will prevent a redundant script element from being included. When set to either true, t or 1 the `<script>` element will not be included in the embed HTML, meaning that pages must include a reference to widgets.js manually. Defaults to false.
|
221
|
-
# @option options [String] :align Specifies whether the embedded Tweet should be left aligned, right aligned, or centered in the page. Valid values are left, right, center, and none. Defaults to none, meaning no alignment styles are specified for the Tweet.
|
222
|
-
# @option options [String] :related A value for the TWT related parameter, as described in {https://dev.twitter.com/docs/intents Web Intents}. This value will be forwarded to all Web Intents calls.
|
223
|
-
# @option options [String] :lang Language code for the rendered embed. This will affect the text and localization of the rendered HTML.
|
224
|
-
# @example Return oEmbeds for Tweet with the ID 25938088801
|
225
|
-
# Twitter.status_with_activity(25938088801)
|
226
|
-
def oembed(id_or_url, options={})
|
227
|
-
key = id_or_url.is_a?(String) && id_or_url.match(%r{^https?://}i) ? "url" : "id"
|
228
|
-
object_from_response(Twitter::OEmbed, :get, "/1.1/statuses/oembed.json?#{key}=#{id_or_url}", options)
|
229
|
-
end
|
230
|
-
|
231
|
-
# Returns oEmbeds for Tweets
|
232
|
-
#
|
233
|
-
# @see https://dev.twitter.com/docs/api/1.1/get/statuses/oembed
|
234
|
-
# @rate_limited Yes
|
235
|
-
# @authentication Requires user context
|
236
|
-
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
237
|
-
# @return [Array<Twitter::OEmbed>] OEmbeds for the requested Tweets.
|
238
|
-
# @overload oembed(*ids_or_urls)
|
239
|
-
# @param ids_or_urls [Array<Integer, String>, Set<Integer, String>] An array of Tweet IDs or URLs.
|
240
|
-
# @example Return oEmbeds for Tweets with the ID 25938088801
|
241
|
-
# Twitter.status_with_activity(25938088801)
|
242
|
-
# @overload oembed(*ids_or_urls, options)
|
243
|
-
# @param ids_or_urls [Array<Integer, String>, Set<Integer, String>] An array of Tweet IDs or URLs.
|
244
|
-
# @param options [Hash] A customizable set of options.
|
245
|
-
# @option options [Integer] :maxwidth The maximum width in pixels that the embed should be rendered at. This value is constrained to be between 250 and 550 pixels.
|
246
|
-
# @option options [Boolean, String, Integer] :hide_media Specifies whether the embedded Tweet should automatically expand images which were uploaded via {https://dev.twitter.com/docs/api/1.1/post/statuses/update_with_media POST statuses/update_with_media}. When set to either true, t or 1 images will not be expanded. Defaults to false.
|
247
|
-
# @option options [Boolean, String, Integer] :hide_thread Specifies whether the embedded Tweet should automatically show the original message in the case that the embedded Tweet is a reply. When set to either true, t or 1 the original Tweet will not be shown. Defaults to false.
|
248
|
-
# @option options [Boolean, String, Integer] :omit_script Specifies whether the embedded Tweet HTML should include a `<script>` element pointing to widgets.js. In cases where a page already includes widgets.js, setting this value to true will prevent a redundant script element from being included. When set to either true, t or 1 the `<script>` element will not be included in the embed HTML, meaning that pages must include a reference to widgets.js manually. Defaults to false.
|
249
|
-
# @option options [String] :align Specifies whether the embedded Tweet should be left aligned, right aligned, or centered in the page. Valid values are left, right, center, and none. Defaults to none, meaning no alignment styles are specified for the Tweet.
|
250
|
-
# @option options [String] :related A value for the TWT related parameter, as described in {https://dev.twitter.com/docs/intents Web Intents}. This value will be forwarded to all Web Intents calls.
|
251
|
-
# @option options [String] :lang Language code for the rendered embed. This will affect the text and localization of the rendered HTML.
|
252
|
-
def oembeds(*args)
|
253
|
-
arguments = Twitter::API::Arguments.new(args)
|
254
|
-
arguments.flatten.threaded_map do |id_or_url|
|
255
|
-
oembed(id_or_url, arguments.options)
|
256
|
-
end
|
257
|
-
end
|
258
|
-
|
259
|
-
# Returns a collection of user IDs belonging to users who have retweeted the specified Tweet.
|
260
|
-
#
|
261
|
-
# @see https://dev.twitter.com/docs/api/1.1/get/statuses/retweeters/ids
|
262
|
-
# @rate_limited Yes
|
263
|
-
# @authentication Required
|
264
|
-
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
265
|
-
# @return [Array<Integer>]
|
266
|
-
# @overload retweeters_ids(options)
|
267
|
-
# @param options [Hash] A customizable set of options.
|
268
|
-
# @example Return a collection of user IDs belonging to users who have retweeted the specified Tweet
|
269
|
-
# Twitter.retweeters_ids({:id => 25938088801})
|
270
|
-
# @overload retweeters_ids(id, options={})
|
271
|
-
# @param id [Integer] The numerical ID of the desired Tweet.
|
272
|
-
# @param options [Hash] A customizable set of options.
|
273
|
-
# @example Return a collection of user IDs belonging to users who have retweeted the specified Tweet
|
274
|
-
# Twitter.retweeters_ids(25938088801)
|
275
|
-
def retweeters_ids(*args)
|
276
|
-
arguments = Twitter::API::Arguments.new(args)
|
277
|
-
arguments.options[:id] ||= arguments.first
|
278
|
-
cursor_from_response(:ids, nil, :get, "/1.1/statuses/retweeters/ids.json", arguments.options, :retweeters_ids)
|
279
|
-
end
|
280
|
-
|
281
|
-
private
|
282
|
-
|
283
|
-
# @param request_method [Symbol]
|
284
|
-
# @param path [String]
|
285
|
-
# @param args [Array]
|
286
|
-
# @return [Array<Twitter::Tweet>]
|
287
|
-
def threaded_tweets_from_response(request_method, path, args)
|
288
|
-
arguments = Twitter::API::Arguments.new(args)
|
289
|
-
arguments.flatten.threaded_map do |id|
|
290
|
-
object_from_response(Twitter::Tweet, request_method, path + "/#{id}.json", arguments.options)
|
291
|
-
end
|
292
|
-
end
|
293
|
-
|
294
|
-
def post_retweet(id, options)
|
295
|
-
response = post("/1.1/statuses/retweet/#{id}.json", options)
|
296
|
-
retweeted_status = response.dup
|
297
|
-
retweeted_status[:body] = response[:body].delete(:retweeted_status)
|
298
|
-
retweeted_status[:body][:retweeted_status] = response[:body]
|
299
|
-
Twitter::Tweet.from_response(retweeted_status)
|
300
|
-
end
|
301
|
-
|
302
|
-
end
|
303
|
-
end
|
304
|
-
end
|
@@ -1,97 +0,0 @@
|
|
1
|
-
require 'twitter/action_factory'
|
2
|
-
require 'twitter/api/arguments'
|
3
|
-
require 'twitter/api/utils'
|
4
|
-
require 'twitter/cursor'
|
5
|
-
require 'twitter/tweet'
|
6
|
-
require 'twitter/user'
|
7
|
-
|
8
|
-
module Twitter
|
9
|
-
module API
|
10
|
-
module Undocumented
|
11
|
-
include Twitter::API::Utils
|
12
|
-
|
13
|
-
# @note Undocumented
|
14
|
-
# @rate_limited Yes
|
15
|
-
# @authentication Requires user context
|
16
|
-
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
17
|
-
#
|
18
|
-
# @overload following_followers_of(options={})
|
19
|
-
# Returns users following followers of the specified user
|
20
|
-
#
|
21
|
-
# @param options [Hash] A customizable set of options.
|
22
|
-
# @option options [Integer] :cursor (-1) Breaks the results into pages. Provide values as returned in the response objects's next_cursor and previous_cursor attributes to page back and forth in the list.
|
23
|
-
# @return [Twitter::Cursor]
|
24
|
-
# @example Return users follow followers of @sferik
|
25
|
-
# Twitter.following_followers_of
|
26
|
-
#
|
27
|
-
# @overload following_followers_of(user, options={})
|
28
|
-
# Returns users following followers of the authenticated user
|
29
|
-
#
|
30
|
-
# @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, or object.
|
31
|
-
# @param options [Hash] A customizable set of options.
|
32
|
-
# @option options [Integer] :cursor (-1) Breaks the results into pages. Provide values as returned in the response objects's next_cursor and previous_cursor attributes to page back and forth in the list.
|
33
|
-
# @return [Twitter::Cursor]
|
34
|
-
# @example Return users follow followers of @sferik
|
35
|
-
# Twitter.following_followers_of('sferik')
|
36
|
-
# Twitter.following_followers_of(7505382) # Same as above
|
37
|
-
def following_followers_of(*args)
|
38
|
-
cursor_from_response_with_user(:users, Twitter::User, :get, "/users/following_followers_of.json", args, :following_followers_of)
|
39
|
-
end
|
40
|
-
|
41
|
-
# Returns activity summary for a Tweet
|
42
|
-
#
|
43
|
-
# @note Undocumented
|
44
|
-
# @rate_limited Yes
|
45
|
-
# @authentication Requires user context
|
46
|
-
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
47
|
-
# @return [Twitter::Tweet] The requested Tweet.
|
48
|
-
# @param id [Integer] A Tweet ID.
|
49
|
-
# @param options [Hash] A customizable set of options.
|
50
|
-
# @example Return activity summary for the Tweet with the ID 25938088801
|
51
|
-
# Twitter.status_activity(25938088801)
|
52
|
-
def status_activity(id, options={})
|
53
|
-
response = get("/i/statuses/#{id}/activity/summary.json", options)
|
54
|
-
response[:body].merge!(:id => id) if response[:body]
|
55
|
-
Twitter::Tweet.from_response(response)
|
56
|
-
end
|
57
|
-
alias tweet_activity status_activity
|
58
|
-
|
59
|
-
# Returns activity summary for Tweets
|
60
|
-
#
|
61
|
-
# @note Undocumented
|
62
|
-
# @rate_limited Yes
|
63
|
-
# @authentication Requires user context
|
64
|
-
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
65
|
-
# @return [Array<Twitter::Tweet>] The requested Tweets.
|
66
|
-
# @overload statuses_activity(*ids)
|
67
|
-
# @param ids [Array<Integer>, Set<Integer>] An array of Tweet IDs.
|
68
|
-
# @example Return activity summary for the Tweet with the ID 25938088801
|
69
|
-
# Twitter.statuses_activity(25938088801)
|
70
|
-
# @overload statuses_activity(*ids, options)
|
71
|
-
# @param ids [Array<Integer>, Set<Integer>] An array of Tweet IDs.
|
72
|
-
# @param options [Hash] A customizable set of options.
|
73
|
-
def statuses_activity(*args)
|
74
|
-
arguments = Twitter::API::Arguments.new(args)
|
75
|
-
arguments.flatten.threaded_map do |id|
|
76
|
-
status_activity(id, arguments.options)
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
# Returns Tweets count for a URL
|
81
|
-
#
|
82
|
-
# @note Undocumented
|
83
|
-
# @rate_limited No
|
84
|
-
# @authentication Not required
|
85
|
-
# @return [Integer]
|
86
|
-
# @param url [Integer] A URL.
|
87
|
-
# @param options [Hash] A customizable set of options.
|
88
|
-
# @example Return Tweet count for http://twitter.com
|
89
|
-
# Twitter.tweet_count("http://twitter.com/")
|
90
|
-
def tweet_count(url, options={})
|
91
|
-
connection = Faraday.new("https://cdn.api.twitter.com", @connection_options.merge(:builder => @middleware))
|
92
|
-
connection.get("/1/urls/count.json", options.merge(:url => url)).body[:count]
|
93
|
-
end
|
94
|
-
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|