ifttt-twitter 2.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gemtest +0 -0
- data/.gitignore +12 -0
- data/.rspec +2 -0
- data/.travis.yml +9 -0
- data/.yardopts +8 -0
- data/Gemfile +7 -0
- data/HISTORY.md +520 -0
- data/LICENSE.md +20 -0
- data/README.md +251 -0
- data/Rakefile +13 -0
- data/lib/twitter.rb +24 -0
- data/lib/twitter/action.rb +9 -0
- data/lib/twitter/action_factory.rb +28 -0
- data/lib/twitter/authenticatable.rb +24 -0
- data/lib/twitter/base.rb +40 -0
- data/lib/twitter/client.rb +126 -0
- data/lib/twitter/client/accounts.rb +180 -0
- data/lib/twitter/client/activity.rb +48 -0
- data/lib/twitter/client/block.rb +104 -0
- data/lib/twitter/client/direct_messages.rb +110 -0
- data/lib/twitter/client/favorites.rb +82 -0
- data/lib/twitter/client/friends_and_followers.rb +293 -0
- data/lib/twitter/client/help.rb +38 -0
- data/lib/twitter/client/legal.rb +32 -0
- data/lib/twitter/client/lists.rb +643 -0
- data/lib/twitter/client/local_trends.rb +46 -0
- data/lib/twitter/client/notification.rb +49 -0
- data/lib/twitter/client/places_and_geo.rb +113 -0
- data/lib/twitter/client/saved_searches.rb +73 -0
- data/lib/twitter/client/search.rb +94 -0
- data/lib/twitter/client/spam_reporting.rb +30 -0
- data/lib/twitter/client/suggested_users.rb +60 -0
- data/lib/twitter/client/timelines.rb +265 -0
- data/lib/twitter/client/trends.rb +55 -0
- data/lib/twitter/client/tweets.rb +191 -0
- data/lib/twitter/client/urls.rb +26 -0
- data/lib/twitter/client/users.rb +203 -0
- data/lib/twitter/config.rb +106 -0
- data/lib/twitter/configuration.rb +20 -0
- data/lib/twitter/connection.rb +43 -0
- data/lib/twitter/core_ext/hash.rb +81 -0
- data/lib/twitter/creatable.rb +14 -0
- data/lib/twitter/cursor.rb +44 -0
- data/lib/twitter/direct_message.rb +27 -0
- data/lib/twitter/error.rb +37 -0
- data/lib/twitter/error/bad_gateway.rb +7 -0
- data/lib/twitter/error/bad_request.rb +7 -0
- data/lib/twitter/error/client_error.rb +7 -0
- data/lib/twitter/error/enhance_your_calm.rb +13 -0
- data/lib/twitter/error/forbidden.rb +7 -0
- data/lib/twitter/error/internal_server_error.rb +7 -0
- data/lib/twitter/error/not_acceptable.rb +7 -0
- data/lib/twitter/error/not_found.rb +7 -0
- data/lib/twitter/error/server_error.rb +7 -0
- data/lib/twitter/error/service_unavailable.rb +7 -0
- data/lib/twitter/error/unauthorized.rb +7 -0
- data/lib/twitter/favorite.rb +28 -0
- data/lib/twitter/follow.rb +27 -0
- data/lib/twitter/geo_factory.rb +22 -0
- data/lib/twitter/language.rb +7 -0
- data/lib/twitter/list.rb +22 -0
- data/lib/twitter/list_member_added.rb +36 -0
- data/lib/twitter/media_factory.rb +21 -0
- data/lib/twitter/mention.rb +43 -0
- data/lib/twitter/metadata.rb +7 -0
- data/lib/twitter/oembed.rb +8 -0
- data/lib/twitter/photo.rb +24 -0
- data/lib/twitter/place.rb +36 -0
- data/lib/twitter/point.rb +27 -0
- data/lib/twitter/polygon.rb +14 -0
- data/lib/twitter/rate_limit_status.rb +15 -0
- data/lib/twitter/relationship.rb +18 -0
- data/lib/twitter/reply.rb +36 -0
- data/lib/twitter/request.rb +38 -0
- data/lib/twitter/request/gateway.rb +20 -0
- data/lib/twitter/request/multipart_with_file.rb +37 -0
- data/lib/twitter/request/oauth.rb +26 -0
- data/lib/twitter/request/phoenix.rb +22 -0
- data/lib/twitter/response/parse_json.rb +28 -0
- data/lib/twitter/response/raise_client_error.rb +49 -0
- data/lib/twitter/response/raise_server_error.rb +23 -0
- data/lib/twitter/retweet.rb +36 -0
- data/lib/twitter/saved_search.rb +16 -0
- data/lib/twitter/settings.rb +17 -0
- data/lib/twitter/size.rb +16 -0
- data/lib/twitter/status.rb +80 -0
- data/lib/twitter/suggestion.rb +22 -0
- data/lib/twitter/trend.rb +14 -0
- data/lib/twitter/user.rb +65 -0
- data/lib/twitter/version.rb +30 -0
- data/spec/faraday/request_spec.rb +25 -0
- data/spec/faraday/response_spec.rb +68 -0
- data/spec/fixtures/about_me.json +1 -0
- data/spec/fixtures/all.json +1 -0
- data/spec/fixtures/bad_gateway.json +1 -0
- data/spec/fixtures/bad_request.json +1 -0
- data/spec/fixtures/by_friends.json +1 -0
- data/spec/fixtures/category.json +1 -0
- data/spec/fixtures/configuration.json +1 -0
- data/spec/fixtures/contributees.json +1 -0
- data/spec/fixtures/contributors.json +1 -0
- data/spec/fixtures/direct_message.json +1 -0
- data/spec/fixtures/direct_messages.json +1 -0
- data/spec/fixtures/end_session.json +1 -0
- data/spec/fixtures/enhance_your_calm.text +11 -0
- data/spec/fixtures/false.json +1 -0
- data/spec/fixtures/favorites.json +1 -0
- data/spec/fixtures/forbidden.json +1 -0
- data/spec/fixtures/friendships.json +1 -0
- data/spec/fixtures/id_list.json +1 -0
- data/spec/fixtures/ids.json +1 -0
- data/spec/fixtures/image_facets.json +1 -0
- data/spec/fixtures/internal_server_error.json +1 -0
- data/spec/fixtures/languages.json +1 -0
- data/spec/fixtures/list.json +1 -0
- data/spec/fixtures/lists.json +1 -0
- data/spec/fixtures/locations.json +1 -0
- data/spec/fixtures/matching_trends.json +1 -0
- data/spec/fixtures/me.jpeg +0 -0
- data/spec/fixtures/media_timeline.json +1 -0
- data/spec/fixtures/members.json +1 -0
- data/spec/fixtures/n605431196_2079896_558_normal.jpg +0 -0
- data/spec/fixtures/no_user_matches.json +1 -0
- data/spec/fixtures/not_acceptable.json +1 -0
- data/spec/fixtures/not_found.json +1 -0
- data/spec/fixtures/oembed.json +1 -0
- data/spec/fixtures/pengwynn.json +1 -0
- data/spec/fixtures/phoenix_search.phoenix +1 -0
- data/spec/fixtures/place.json +1 -0
- data/spec/fixtures/places.json +1 -0
- data/spec/fixtures/privacy.json +1 -0
- data/spec/fixtures/profile_image.text +24 -0
- data/spec/fixtures/rate_limit_status.json +1 -0
- data/spec/fixtures/recommendations.json +1 -0
- data/spec/fixtures/relationship.json +1 -0
- data/spec/fixtures/resolve.json +1 -0
- data/spec/fixtures/retweet.json +1 -0
- data/spec/fixtures/retweeters_of.json +1 -0
- data/spec/fixtures/retweets.json +1 -0
- data/spec/fixtures/saved_search.json +1 -0
- data/spec/fixtures/saved_searches.json +1 -0
- data/spec/fixtures/search.json +1 -0
- data/spec/fixtures/service_unavailable.json +1 -0
- data/spec/fixtures/settings.json +1 -0
- data/spec/fixtures/sferik.json +1 -0
- data/spec/fixtures/status.json +1 -0
- data/spec/fixtures/status_with_media.json +104 -0
- data/spec/fixtures/statuses.json +1 -0
- data/spec/fixtures/suggestions.json +1 -0
- data/spec/fixtures/tos.json +1 -0
- data/spec/fixtures/totals.json +1 -0
- data/spec/fixtures/trends.json +1 -0
- data/spec/fixtures/trends_current.json +1 -0
- data/spec/fixtures/trends_daily.json +1 -0
- data/spec/fixtures/trends_weekly.json +1 -0
- data/spec/fixtures/true.json +1 -0
- data/spec/fixtures/unauthorized.json +1 -0
- data/spec/fixtures/user_search.json +1 -0
- data/spec/fixtures/user_timeline.json +1 -0
- data/spec/fixtures/users.json +1 -0
- data/spec/fixtures/users_list.json +1 -0
- data/spec/fixtures/video_facets.json +1 -0
- data/spec/fixtures/we_concept_bg2.png +0 -0
- data/spec/helper.rb +49 -0
- data/spec/twitter/action_factory_spec.rb +37 -0
- data/spec/twitter/action_spec.rb +16 -0
- data/spec/twitter/base_spec.rb +29 -0
- data/spec/twitter/client/accounts_spec.rb +181 -0
- data/spec/twitter/client/activity_spec.rb +43 -0
- data/spec/twitter/client/block_spec.rb +106 -0
- data/spec/twitter/client/direct_messages_spec.rb +98 -0
- data/spec/twitter/client/favorites_spec.rb +80 -0
- data/spec/twitter/client/friends_and_followers_spec.rb +478 -0
- data/spec/twitter/client/help_spec.rb +44 -0
- data/spec/twitter/client/legal_spec.rb +41 -0
- data/spec/twitter/client/lists_spec.rb +1104 -0
- data/spec/twitter/client/local_trends_spec.rb +58 -0
- data/spec/twitter/client/notification_spec.rb +47 -0
- data/spec/twitter/client/places_and_geo_spec.rb +100 -0
- data/spec/twitter/client/saved_searches_spec.rb +80 -0
- data/spec/twitter/client/search_spec.rb +92 -0
- data/spec/twitter/client/spam_reporting_spec.rb +28 -0
- data/spec/twitter/client/suggested_users_spec.rb +65 -0
- data/spec/twitter/client/timelines_spec.rb +231 -0
- data/spec/twitter/client/trends_spec.rb +51 -0
- data/spec/twitter/client/tweets_spec.rb +189 -0
- data/spec/twitter/client/urls_spec.rb +31 -0
- data/spec/twitter/client/users_spec.rb +323 -0
- data/spec/twitter/client_spec.rb +94 -0
- data/spec/twitter/configuration_spec.rb +17 -0
- data/spec/twitter/cursor_spec.rb +43 -0
- data/spec/twitter/direct_message_spec.rb +56 -0
- data/spec/twitter/favorite_spec.rb +29 -0
- data/spec/twitter/follow_spec.rb +29 -0
- data/spec/twitter/geo_factory_spec.rb +21 -0
- data/spec/twitter/list_spec.rb +34 -0
- data/spec/twitter/media_factory_spec.rb +17 -0
- data/spec/twitter/mention_spec.rb +52 -0
- data/spec/twitter/oembed_spec.rb +145 -0
- data/spec/twitter/photo_spec.rb +35 -0
- data/spec/twitter/place_spec.rb +75 -0
- data/spec/twitter/point_spec.rb +32 -0
- data/spec/twitter/polygon_spec.rb +18 -0
- data/spec/twitter/rate_limit_status_spec.rb +16 -0
- data/spec/twitter/relationship_spec.rb +27 -0
- data/spec/twitter/reply_spec.rb +41 -0
- data/spec/twitter/retweet_spec.rb +41 -0
- data/spec/twitter/saved_search_spec.rb +34 -0
- data/spec/twitter/settings_spec.rb +16 -0
- data/spec/twitter/size_spec.rb +18 -0
- data/spec/twitter/status_spec.rb +148 -0
- data/spec/twitter/suggestion_spec.rb +20 -0
- data/spec/twitter/trend_spec.rb +20 -0
- data/spec/twitter/user_spec.rb +50 -0
- data/spec/twitter_spec.rb +91 -0
- data/twitter.gemspec +42 -0
- metadata +564 -0
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'twitter/place'
|
2
|
+
require 'twitter/trend'
|
3
|
+
|
4
|
+
module Twitter
|
5
|
+
class Client
|
6
|
+
# Defines methods related to local trends
|
7
|
+
# @see Twitter::Client::Trends
|
8
|
+
module LocalTrends
|
9
|
+
|
10
|
+
# Returns the top 10 trending topics for a specific WOEID
|
11
|
+
#
|
12
|
+
# @see https://dev.twitter.com/docs/api/1/get/trends/:woeid
|
13
|
+
# @rate_limited Yes
|
14
|
+
# @requires_authentication No
|
15
|
+
# @param woeid [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::Client::LocalTrends#trend_locations}. Global information is available by using 1 as the WOEID.
|
16
|
+
# @param options [Hash] A customizable set of options.
|
17
|
+
# @option options [String] :exclude Setting this equal to 'hashtags' will remove all hashtags from the trends list.
|
18
|
+
# @return [Array<Twitter::Trend>]
|
19
|
+
# @example Return the top 10 trending topics for San Francisco
|
20
|
+
# Twitter.local_trends(2487956)
|
21
|
+
def local_trends(woeid=1, options={})
|
22
|
+
get("/1/trends/#{woeid}.json", options).first['trends'].map do |trend|
|
23
|
+
Twitter::Trend.new(trend)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
# Returns the locations that Twitter has trending topic information for
|
28
|
+
#
|
29
|
+
# @see https://dev.twitter.com/docs/api/1/get/trends/available
|
30
|
+
# @rate_limited Yes
|
31
|
+
# @requires_authentication No
|
32
|
+
# @param options [Hash] A customizable set of options.
|
33
|
+
# @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.
|
34
|
+
# @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.
|
35
|
+
# @return [Array<Twitter::Place>]
|
36
|
+
# @example Return the locations that Twitter has trending topic information for
|
37
|
+
# Twitter.trend_locations
|
38
|
+
def trend_locations(options={})
|
39
|
+
get("/1/trends/available.json", options).map do |place|
|
40
|
+
Twitter::Place.new(place)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'twitter/core_ext/hash'
|
2
|
+
require 'twitter/user'
|
3
|
+
|
4
|
+
module Twitter
|
5
|
+
class Client
|
6
|
+
# Defines methods related to notification
|
7
|
+
module Notification
|
8
|
+
|
9
|
+
# Enables device notifications for updates from the specified user to the authenticating user
|
10
|
+
#
|
11
|
+
# @see https://dev.twitter.com/docs/api/1/post/notifications/follow
|
12
|
+
# @rate_limited No
|
13
|
+
# @requires_authentication Yes
|
14
|
+
# @param user [Integer, String] A Twitter user ID or screen name.
|
15
|
+
# @param options [Hash] A customizable set of options.
|
16
|
+
# @option options [Boolean, String, Integer] :include_entities Include {https://dev.twitter.com/docs/tweet-entities Tweet Entities} when set to true, 't' or 1.
|
17
|
+
# @return [Twitter::User] The specified user.
|
18
|
+
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
19
|
+
# @example Enable device notifications for updates from @sferik
|
20
|
+
# Twitter.enable_notifications("sferik")
|
21
|
+
# Twitter.enable_notifications(7505382) # Same as above
|
22
|
+
def enable_notifications(user, options={})
|
23
|
+
options.merge_user!(user)
|
24
|
+
user = post("/1/notifications/follow.json", options)
|
25
|
+
Twitter::User.new(user)
|
26
|
+
end
|
27
|
+
|
28
|
+
# Disables notifications for updates from the specified user to the authenticating user
|
29
|
+
#
|
30
|
+
# @see https://dev.twitter.com/docs/api/1/post/notifications/leave
|
31
|
+
# @rate_limited No
|
32
|
+
# @requires_authentication Yes
|
33
|
+
# @param user [Integer, String] A Twitter user ID or screen name.
|
34
|
+
# @param options [Hash] A customizable set of options.
|
35
|
+
# @option options [Boolean, String, Integer] :include_entities Include {https://dev.twitter.com/docs/tweet-entities Tweet Entities} when set to true, 't' or 1.
|
36
|
+
# @return [Twitter::User] The specified user.
|
37
|
+
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
38
|
+
# @example Disable device notifications for updates from @sferik
|
39
|
+
# Twitter.disable_notifications("sferik")
|
40
|
+
# Twitter.disable_notifications(7505382) # Same as above
|
41
|
+
def disable_notifications(user, options={})
|
42
|
+
options.merge_user!(user)
|
43
|
+
user = post("/1/notifications/leave.json", options)
|
44
|
+
Twitter::User.new(user)
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,113 @@
|
|
1
|
+
require 'twitter/place'
|
2
|
+
|
3
|
+
module Twitter
|
4
|
+
class Client
|
5
|
+
# Defines methods related to geography
|
6
|
+
# @see https://dev.twitter.com/terms/geo-developer-guidelines Developer Guidelines
|
7
|
+
module PlacesAndGeo
|
8
|
+
|
9
|
+
# Search for places that can be attached to a {Twitter::Client::Tweets#update}
|
10
|
+
#
|
11
|
+
# @see https://dev.twitter.com/docs/api/1/get/geo/search
|
12
|
+
# @rate_limited Yes
|
13
|
+
# @requires_authentication No
|
14
|
+
# @param options [Hash] A customizable set of options.
|
15
|
+
# @option options [Float] :lat The latitude to search around. 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.
|
16
|
+
# @option options [Float] :long The longitude to search around. The valid range 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.
|
17
|
+
# @option options [String] :query Free-form text to match against while executing a geo-based query, best suited for finding nearby locations by name.
|
18
|
+
# @option options [String] :ip An IP address. Used when attempting to fix geolocation based off of the user's IP address.
|
19
|
+
# @option options [String] :granularity ('neighborhood') This is the minimal granularity of place types to return and must be one of: 'poi', 'neighborhood', 'city', 'admin' or 'country'.
|
20
|
+
# @option options [String] :accuracy ('0m') A hint on the "region" in which to search. If a number, then this is a radius in meters, but it can also take a string that is suffixed with ft to specify feet. If coming from a device, in practice, this value is whatever accuracy the device has measuring its location (whether it be coming from a GPS, WiFi triangulation, etc.).
|
21
|
+
# @option options [Integer] :max_results A hint as to the number of results to return. This does not guarantee that the number of results returned will equal max_results, but instead informs how many "nearby" results to return. Ideally, only pass in the number of places you intend to display to the user here.
|
22
|
+
# @option options [String] :contained_within This is the place_id which you would like to restrict the search results to. Setting this value means only places within the given place_id will be found.
|
23
|
+
# @option options [String] :"attribute:street_address" This option searches for places which have this given street address. There are other well-known and application-specific attributes available. Custom attributes are also permitted.
|
24
|
+
# @return [Array<Twitter::Place>]
|
25
|
+
# @example Return an array of places near the IP address 74.125.19.104
|
26
|
+
# Twitter.places_nearby(:ip => "74.125.19.104")
|
27
|
+
def places_nearby(options={})
|
28
|
+
get("/1/geo/search.json", options)['result']['places'].map do |place|
|
29
|
+
Twitter::Place.new(place)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
alias :geo_search :places_nearby
|
33
|
+
|
34
|
+
# Locates places near the given coordinates which are similar in name
|
35
|
+
#
|
36
|
+
# @see https://dev.twitter.com/docs/api/1/get/geo/similar_places
|
37
|
+
# @note 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::Client::Geo#place} to create a new one. The token contained in the response is the token necessary to create a new place.
|
38
|
+
# @rate_limited Yes
|
39
|
+
# @requires_authentication No
|
40
|
+
# @param options [Hash] A customizable set of options.
|
41
|
+
# @option options [Float] :lat The latitude to search around. 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.
|
42
|
+
# @option options [Float] :long The longitude to search around. The valid range 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.
|
43
|
+
# @option options [String] :name The name a place is known as.
|
44
|
+
# @option options [String] :contained_within This is the place_id which you would like to restrict the search results to. Setting this value means only places within the given place_id will be found.
|
45
|
+
# @option options [String] :"attribute:street_address" This option searches for places which have this given street address. There are other well-known and application-specific attributes available. Custom attributes are also permitted.
|
46
|
+
# @return [Array<Twitter::Place>]
|
47
|
+
# @example Return an array of places similar to Twitter HQ
|
48
|
+
# Twitter.places_similar(:lat => "37.7821120598956", :long => "-122.400612831116", :name => "Twitter HQ")
|
49
|
+
def places_similar(options={})
|
50
|
+
get("/1/geo/similar_places.json", options)['result']['places'].map do |place|
|
51
|
+
Twitter::Place.new(place)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
# Searches for up to 20 places that can be used as a place_id
|
56
|
+
#
|
57
|
+
# @see https://dev.twitter.com/docs/api/1/get/geo/reverse_geocode
|
58
|
+
# @note This request is an informative call and will deliver generalized results about geography.
|
59
|
+
# @rate_limited Yes
|
60
|
+
# @requires_authentication No
|
61
|
+
# @param options [Hash] A customizable set of options.
|
62
|
+
# @option options [Float] :lat The latitude to search around. 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.
|
63
|
+
# @option options [Float] :long The longitude to search around. The valid range 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.
|
64
|
+
# @option options [String] :accuracy ('0m') A hint on the "region" in which to search. If a number, then this is a radius in meters, but it can also take a string that is suffixed with ft to specify feet. If coming from a device, in practice, this value is whatever accuracy the device has measuring its location (whether it be coming from a GPS, WiFi triangulation, etc.).
|
65
|
+
# @option options [String] :granularity ('neighborhood') This is the minimal granularity of place types to return and must be one of: 'poi', 'neighborhood', 'city', 'admin' or 'country'.
|
66
|
+
# @option options [Integer] :max_results A hint as to the number of results to return. This does not guarantee that the number of results returned will equal max_results, but instead informs how many "nearby" results to return. Ideally, only pass in the number of places you intend to display to the user here.
|
67
|
+
# @return [Array<Twitter::Place>]
|
68
|
+
# @example Return an array of places within the specified region
|
69
|
+
# Twitter.reverse_geocode(:lat => "37.7821120598956", :long => "-122.400612831116")
|
70
|
+
def reverse_geocode(options={})
|
71
|
+
get("/1/geo/reverse_geocode.json", options)['result']['places'].map do |place|
|
72
|
+
Twitter::Place.new(place)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
# Returns all the information about a known place
|
77
|
+
#
|
78
|
+
# @see https://dev.twitter.com/docs/api/1/get/geo/id/:place_id
|
79
|
+
# @rate_limited Yes
|
80
|
+
# @requires_authentication No
|
81
|
+
# @param place_id [String] A place in the world. These IDs can be retrieved from {Twitter::Client::Geo#reverse_geocode}.
|
82
|
+
# @param options [Hash] A customizable set of options.
|
83
|
+
# @return [Twitter::Place] The requested place.
|
84
|
+
# @example Return all the information about Twitter HQ
|
85
|
+
# Twitter.place("247f43d441defc03")
|
86
|
+
def place(place_id, options={})
|
87
|
+
place = get("/1/geo/id/#{place_id}.json", options)
|
88
|
+
Twitter::Place.new(place)
|
89
|
+
end
|
90
|
+
|
91
|
+
# Creates a new place at the given latitude and longitude
|
92
|
+
#
|
93
|
+
# @see https://dev.twitter.com/docs/api/1/post/geo/place
|
94
|
+
# @rate_limited Yes
|
95
|
+
# @requires_authentication No
|
96
|
+
# @param options [Hash] A customizable set of options.
|
97
|
+
# @option options [String] :name The name a place is known as.
|
98
|
+
# @option options [String] :contained_within This is the place_id which you would like to restrict the search results to. Setting this value means only places within the given place_id will be found.
|
99
|
+
# @option options [String] :token The token found in the response from {Twitter::Client::Geo#places_similar}.
|
100
|
+
# @option options [Float] :lat The latitude to search around. 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.
|
101
|
+
# @option options [Float] :long The longitude to search around. The valid range 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.
|
102
|
+
# @option options [String] :"attribute:street_address" This option searches for places which have this given street address. There are other well-known and application-specific attributes available. Custom attributes are also permitted.
|
103
|
+
# @return [Twitter::Place] The created place.
|
104
|
+
# @example Create a new place
|
105
|
+
# Twitter.place_create(:name => "@sferik's Apartment", :token => "22ff5b1f7159032cf69218c4d8bb78bc", :contained_within => "41bcb736f84a799e", :lat => "37.783699", :long => "-122.393581")
|
106
|
+
def place_create(options={})
|
107
|
+
place = post("/1/geo/place.json", options)
|
108
|
+
Twitter::Place.new(place)
|
109
|
+
end
|
110
|
+
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
require 'twitter/saved_search'
|
2
|
+
|
3
|
+
module Twitter
|
4
|
+
class Client
|
5
|
+
# Defines methods related to saved searches
|
6
|
+
module SavedSearches
|
7
|
+
|
8
|
+
# Returns the authenticated user's saved search queries
|
9
|
+
#
|
10
|
+
# @see https://dev.twitter.com/docs/api/1/get/saved_searches
|
11
|
+
# @rate_limited Yes
|
12
|
+
# @requires_authentication Yes
|
13
|
+
# @param options [Hash] A customizable set of options.
|
14
|
+
# @return [Array<Twitter::SavedSearch>] Saved search queries.
|
15
|
+
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
16
|
+
# @example Return the authenticated user's saved search queries
|
17
|
+
# Twitter.saved_searches
|
18
|
+
def saved_searches(options={})
|
19
|
+
get("/1/saved_searches.json", options).map do |saved_search|
|
20
|
+
Twitter::SavedSearch.new(saved_search)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
# Retrieve the data for a saved search owned by the authenticating user specified by the given ID
|
25
|
+
#
|
26
|
+
# @see https://dev.twitter.com/docs/api/1/get/saved_searches/show/:id
|
27
|
+
# @rate_limited Yes
|
28
|
+
# @requires_authentication Yes
|
29
|
+
# @param id [Integer] The ID of the saved search.
|
30
|
+
# @param options [Hash] A customizable set of options.
|
31
|
+
# @return [Twitter::SavedSearch] The saved search.
|
32
|
+
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
33
|
+
# @example Retrieve the data for a saved search owned by the authenticating user with the ID 16129012
|
34
|
+
# Twitter.saved_search(16129012)
|
35
|
+
def saved_search(id, options={})
|
36
|
+
saved_search = get("/1/saved_searches/show/#{id}.json", options)
|
37
|
+
Twitter::SavedSearch.new(saved_search)
|
38
|
+
end
|
39
|
+
|
40
|
+
# Creates a saved search for the authenticated user
|
41
|
+
#
|
42
|
+
# @see https://dev.twitter.com/docs/api/1/post/saved_searches/create
|
43
|
+
# @rate_limited No
|
44
|
+
# @requires_authentication Yes
|
45
|
+
# @param query [String] The query of the search the user would like to save.
|
46
|
+
# @param options [Hash] A customizable set of options.
|
47
|
+
# @return [Twitter::SavedSearch] The created saved search.
|
48
|
+
# @example Create a saved search for the authenticated user with the query "twitter"
|
49
|
+
# Twitter.saved_search_create("twitter")
|
50
|
+
def saved_search_create(query, options={})
|
51
|
+
saved_search = post("/1/saved_searches/create.json", options.merge(:query => query))
|
52
|
+
Twitter::SavedSearch.new(saved_search)
|
53
|
+
end
|
54
|
+
|
55
|
+
# Destroys a saved search for the authenticated user
|
56
|
+
#
|
57
|
+
# @see https://dev.twitter.com/docs/api/1/post/saved_searches/destroy/:id
|
58
|
+
# @note The search specified by ID must be owned by the authenticating user.
|
59
|
+
# @rate_limited No
|
60
|
+
# @requires_authentication Yes
|
61
|
+
# @param id [Integer] The ID of the saved search.
|
62
|
+
# @param options [Hash] A customizable set of options.
|
63
|
+
# @return [Twitter::SavedSearch] The deleted saved search.
|
64
|
+
# @example Destroys a saved search for the authenticated user with the ID 16129012
|
65
|
+
# Twitter.saved_search_destroy(16129012)
|
66
|
+
def saved_search_destroy(id, options={})
|
67
|
+
saved_search = delete("/1/saved_searches/destroy/#{id}.json", options)
|
68
|
+
Twitter::SavedSearch.new(saved_search)
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,94 @@
|
|
1
|
+
require 'twitter/status'
|
2
|
+
|
3
|
+
module Twitter
|
4
|
+
class Client
|
5
|
+
# Defines methods related to Search
|
6
|
+
module Search
|
7
|
+
|
8
|
+
# Returns recent statuses that contain images related to a query
|
9
|
+
#
|
10
|
+
# @note Undocumented
|
11
|
+
# @rate_limited Yes
|
12
|
+
# @requires_authentication No
|
13
|
+
# @param q [String] A search term.
|
14
|
+
# @param options [Hash] A customizable set of options.
|
15
|
+
# @option options [Integer] :count Specifies the number of records to retrieve. Must be less than or equal to 100.
|
16
|
+
# @option options [Boolean, String, Integer] :include_entities Include {http://dev.twitter.com/pages/tweet_entities Tweet Entities} when set to true, 't' or 1.
|
17
|
+
# @return [Array<Twitter::Status>] An array of statuses that contain images
|
18
|
+
# @example Return recent statuses that contain images related to a query
|
19
|
+
# Twitter.images('twitter')
|
20
|
+
def images(q, options={})
|
21
|
+
get("/i/search/image_facets.json", options.merge(:q => q), :phoenix => true).map do |status|
|
22
|
+
Twitter::Status.new(status)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
# Returns recent statuses that contain videos related to a query
|
27
|
+
#
|
28
|
+
# @note Undocumented
|
29
|
+
# @rate_limited Yes
|
30
|
+
# @requires_authentication No
|
31
|
+
# @param q [String] A search term.
|
32
|
+
# @param options [Hash] A customizable set of options.
|
33
|
+
# @option options [Integer] :count Specifies the number of records to retrieve. Must be less than or equal to 100.
|
34
|
+
# @option options [Boolean, String, Integer] :include_entities Include {http://dev.twitter.com/pages/tweet_entities Tweet Entities} when set to true, 't' or 1.
|
35
|
+
# @return [Array<Twitter::Status>] An array of statuses that contain videos
|
36
|
+
# @example Return recent statuses that contain videos related to a query
|
37
|
+
# Twitter.videos('twitter')
|
38
|
+
def videos(q, options={})
|
39
|
+
get("/i/search/video_facets.json", options.merge(:q => q), :phoenix => true).map do |status|
|
40
|
+
Twitter::Status.new(status)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
# Returns tweets that match a specified query.
|
45
|
+
#
|
46
|
+
# @see https://dev.twitter.com/docs/api/1/get/search
|
47
|
+
# @see https://dev.twitter.com/docs/using-search
|
48
|
+
# @see https://dev.twitter.com/docs/history-rest-search-api
|
49
|
+
# @note As of April 1st 2010, the Search API provides an option to retrieve "popular tweets" in addition to real-time search results. In an upcoming release, this will become the default and clients that don't want to receive popular tweets in their search results will have to explicitly opt-out. See the result_type parameter below for more information.
|
50
|
+
# @rate_limited Yes
|
51
|
+
# @requires_authentication No
|
52
|
+
# @param q [String] A search term.
|
53
|
+
# @param options [Hash] A customizable set of options.
|
54
|
+
# @option options [String] :geocode Returns tweets by users located within a given radius of the given latitude/longitude. The location is preferentially taking from the Geotagging API, but will fall back to their Twitter profile. The parameter value is specified by "latitude,longitude,radius", where radius units must be specified as either "mi" (miles) or "km" (kilometers). Note that you cannot use the near operator via the API to geocode arbitrary locations; however you can use this geocode parameter to search near geocodes directly.
|
55
|
+
# @option options [String] :lang Restricts tweets to the given language, given by an ISO 639-1 code.
|
56
|
+
# @option options [String] :locale Specify the language of the query you are sending (only ja is currently effective). This is intended for language-specific clients and the default should work in the majority of cases.
|
57
|
+
# @option options [Integer] :page The page number (starting at 1) to return, up to a max of roughly 1500 results (based on rpp * page).
|
58
|
+
# @option options [String] :result_type Specifies what type of search results you would prefer to receive. The current default is "mixed."
|
59
|
+
# @option options [Integer] :rpp The number of tweets to return per page, up to a max of 100.
|
60
|
+
# @option options [String] :until Optional. Returns tweets generated before the given date. Date should be formatted as YYYY-MM-DD.
|
61
|
+
# @option options [Integer] :since_id Returns results with an ID greater than (that is, more recent than) the specified ID. There are limits to the number of Tweets which can be accessed through the API. If the limit of Tweets has occured since the since_id, the since_id will be forced to the oldest ID available.
|
62
|
+
# @option options [Boolean, String, Integer] :include_entities Include {http://dev.twitter.com/pages/tweet_entities Tweet Entities} when set to true, 't' or 1.
|
63
|
+
# @option options [Boolean, String, Integer] :with_twitter_user_id When set to either true, t or 1, the from_user_id, from_user_id_str, to_user_id, and to_user_id_str values in the response will map to "official" user IDs which will match those returned by the REST API.
|
64
|
+
# @return [Array<Twitter::Status>] Return tweets that match a specified query
|
65
|
+
# @example Returns tweets related to twitter
|
66
|
+
# Twitter.search('twitter')
|
67
|
+
def search(q, options={})
|
68
|
+
get("/search.json", options.merge(:q => q), :endpoint => search_endpoint)['results'].map do |status|
|
69
|
+
Twitter::Status.new(status)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
# Returns recent statuses related to a query with images and videos embedded
|
74
|
+
#
|
75
|
+
# @note Undocumented
|
76
|
+
# @rate_limited Yes
|
77
|
+
# @requires_authentication No
|
78
|
+
# @param q [String] A search term.
|
79
|
+
# @param options [Hash] A customizable set of options.
|
80
|
+
# @option options [Integer] :count Specifies the number of records to retrieve. Must be less than or equal to 100.
|
81
|
+
# @option options [Boolean, String, Integer] :include_entities Include {http://dev.twitter.com/pages/tweet_entities Tweet Entities} when set to true, 't' or 1.
|
82
|
+
# @option options [Integer] :since_id Returns results with an ID greater than (that is, more recent than) the specified ID.
|
83
|
+
# @return [Array<Twitter::Status>] An array of statuses that contain videos
|
84
|
+
# @example Return recent statuses related to twitter with images and videos embedded
|
85
|
+
# Twitter.phoenix_search('twitter')
|
86
|
+
def phoenix_search(q, options={})
|
87
|
+
get("/phoenix_search.phoenix", options.merge(:q => q), :phoenix => true)['statuses'].map do |status|
|
88
|
+
Twitter::Status.new(status)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'twitter/core_ext/hash'
|
2
|
+
require 'twitter/user'
|
3
|
+
|
4
|
+
module Twitter
|
5
|
+
class Client
|
6
|
+
# Defines methods related to spam reporting
|
7
|
+
# @see Twitter::Client::Block
|
8
|
+
module SpamReporting
|
9
|
+
|
10
|
+
# The user specified is blocked by the authenticated user and reported as a spammer
|
11
|
+
#
|
12
|
+
# @see https://dev.twitter.com/docs/api/1/post/report_spam
|
13
|
+
# @rate_limited Yes
|
14
|
+
# @requires_authentication No
|
15
|
+
# @param user [Integer, String] A Twitter user ID or screen name.
|
16
|
+
# @param options [Hash] A customizable set of options.
|
17
|
+
# @option options [Boolean, String, Integer] :include_entities Include {https://dev.twitter.com/docs/tweet-entities Tweet Entities} when set to true, 't' or 1.
|
18
|
+
# @return [Twitter::User] The reported user.
|
19
|
+
# @example Report @spam for spam
|
20
|
+
# Twitter.report_spam("spam")
|
21
|
+
# Twitter.report_spam(14589771) # Same as above
|
22
|
+
def report_spam(user, options={})
|
23
|
+
options.merge_user!(user)
|
24
|
+
user = post("/1/report_spam.json", options)
|
25
|
+
Twitter::User.new(user)
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'twitter/suggestion'
|
2
|
+
require 'twitter/user'
|
3
|
+
|
4
|
+
module Twitter
|
5
|
+
class Client
|
6
|
+
# Defines methods related to users
|
7
|
+
module SuggestedUsers
|
8
|
+
|
9
|
+
# @overload suggestions(options={})
|
10
|
+
# Returns the list of suggested user categories
|
11
|
+
#
|
12
|
+
# @see https://dev.twitter.com/docs/api/1/get/users/suggestions
|
13
|
+
# @rate_limited Yes
|
14
|
+
# @requires_authentication No
|
15
|
+
# @param options [Hash] A customizable set of options.
|
16
|
+
# @return [Array<Twitter::Suggestion>]
|
17
|
+
# @example Return the list of suggested user categories
|
18
|
+
# Twitter.suggestions
|
19
|
+
# @overload suggestions(slug, options={})
|
20
|
+
# Returns the users in a given category
|
21
|
+
#
|
22
|
+
# @see https://dev.twitter.com/docs/api/1/get/users/suggestions/:slug
|
23
|
+
# @rate_limited Yes
|
24
|
+
# @requires_authentication No
|
25
|
+
# @param slug [String] The short name of list or a category.
|
26
|
+
# @param options [Hash] A customizable set of options.
|
27
|
+
# @return [Array<Twitter::Suggestion>]
|
28
|
+
# @example Return the users in the Art & Design category
|
29
|
+
# Twitter.suggestions("art-design")
|
30
|
+
def suggestions(*args)
|
31
|
+
options = args.last.is_a?(Hash) ? args.pop : {}
|
32
|
+
if slug = args.first
|
33
|
+
suggestion = get("/1/users/suggestions/#{slug}.json", options)
|
34
|
+
Twitter::Suggestion.new(suggestion)
|
35
|
+
else
|
36
|
+
get("/1/users/suggestions.json", options).map do |suggestion|
|
37
|
+
Twitter::Suggestion.new(suggestion)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
# Access the users in a given category of the Twitter suggested user list and return their most recent status if they are not a protected user
|
43
|
+
#
|
44
|
+
# @see https://dev.twitter.com/docs/api/1/get/users/suggestions/:slug/members
|
45
|
+
# @rate_limited Yes
|
46
|
+
# @requires_authentication No
|
47
|
+
# @param slug [String] The short name of list or a category.
|
48
|
+
# @param options [Hash] A customizable set of options.
|
49
|
+
# @return [Array<Twitter::User>]
|
50
|
+
# @example Return the users in the Art & Design category and their most recent status if they are not a protected user
|
51
|
+
# Twitter.suggest_users("art-design")
|
52
|
+
def suggest_users(slug, options={})
|
53
|
+
get("/1/users/suggestions/#{slug}/members.json", options).map do |user|
|
54
|
+
Twitter::User.new(user)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|