Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added saved_searches, spam and upcoming local trends methods

  • Loading branch information...
commit 52e8f18bb4a5d3284ad9fd8bc3067a8c06daf6ba 1 parent cc47ed5
@moomerman authored
View
22 lib/twitter_oauth/blocks.rb
@@ -1,15 +1,33 @@
module TwitterOAuth
class Client
- # unblock this user.
+ # Blocks the user specified in the ID parameter as the authenticating user.
+ # Destroys a friendship to the blocked user if it exists.
+ # Returns the blocked user in the requested format when successful.
def block(id)
post("/blocks/create/#{id}.json")
end
- # block this user.
+ # Un-blocks the user specified in the ID parameter for the authenticating user.
+ # Returns the un-blocked user in the requested format when successful.
def unblock(id)
post("/blocks/destroy/#{id}.json")
end
+ # Returns if the authenticating user is blocking a target user.
+ def blocked?(id)
+ get("/blocks/exists/#{id}.json")
+ end
+
+ # Returns an array of user objects that the authenticating user is blocking.
+ def blocking
+ get("/blocks/blocking.json")
+ end
+
+ # Returns an array of numeric user ids the authenticating user is blocking.
+ def blocking_ids
+ get("/blocks/blocking/ids.json")
+ end
+
end
end
View
7 lib/twitter_oauth/client.rb
@@ -11,6 +11,8 @@
require 'twitter_oauth/utils'
require 'twitter_oauth/trends'
require 'twitter_oauth/lists'
+require 'twitter_oauth/saved_searches'
+require 'twitter_oauth/spam'
module TwitterOAuth
class Client
@@ -36,6 +38,11 @@ def show(username)
get("/users/show/#{username}.json")
end
+ # Returns the string "ok" in the requested format with a 200 OK HTTP status code.
+ def test
+ get("/help/test.json")
+ end
+
def request_token(options={})
consumer.get_request_token(options)
end
View
5 lib/twitter_oauth/favorites.rb
@@ -1,14 +1,19 @@
module TwitterOAuth
class Client
+ # Returns the 20 most recent favorite statuses for the authenticating user or user specified by the ID parameter.
def favorites(page=1)
get("/favorites.json?page=#{page}")
end
+ # Favorites the status specified in the ID parameter as the authenticating user.
+ # Returns the favorite status when successful.
def favorite
post("/favorites/create/#{id}.json")
end
+ # Un-favorites the status specified in the ID parameter as the authenticating user.
+ # Returns the un-favorited status when successful.
def unfavorite
post("/favorites/destroy/#{id}.json")
end
View
16 lib/twitter_oauth/friendships.rb
@@ -1,31 +1,39 @@
module TwitterOAuth
class Client
+ # Returns an array of numeric IDs for every user the specified user is following.
def friends_ids(options={})
args = options.map{|k,v| "#{k}=#{v}"}.join('&')
get("/friends/ids.json?#{args}")
end
+ # Returns an array of numeric IDs for every user following the specified user.
def followers_ids(options={})
args = options.map{|k,v| "#{k}=#{v}"}.join('&')
get("/followers/ids.json?#{args}")
end
- # friend this user.
+ # Allows the authenticating user to follow the specified user. Returns the befriended user when successful.
def friend(id)
post("/friendships/create/#{id}.json")
end
- # unfriend.
+ # Allows the authenticating users to unfollow the specified user. Returns the unfollowed user when successful.
def unfriend(id)
post("/friendships/destroy/#{id}.json")
end
- # exists?.
- def exists?(a, b)
+ # Tests for the existence of friendship between two users. Will return true if user_a follows user_b, otherwise will return false.
+ # You are better off using get_friendship as it returns more extended information.
+ def friends?(a, b)
oauth_response = access_token.get("/friendships/exists.json?user_a=#{a}&user_b=#{b}")
oauth_response.body.strip == 'true'
end
+ # Returns detailed information about the relationship between two users.
+ def get_friendship(a, b)
+ get("/friendships/show.json?source_screen_name=#{a}&target_screen_name=#{b}")
+ end
+
end
end
View
6 lib/twitter_oauth/notifications.rb
@@ -1,12 +1,14 @@
module TwitterOAuth
class Client
- # follow this user.
+ # Enables device notifications for updates from the specified user.
+ # Returns the specified user when successful.
def follow(id)
post("/notifications/follow/#{id}.json")
end
- # unfollow.
+ # Disables notifications for updates from the specified user to the authenticating user.
+ # Returns the specified user when successful.
def leave(id)
post("/notifications/leave/#{id}.json")
end
View
24 lib/twitter_oauth/saved_searches.rb
@@ -0,0 +1,24 @@
+module TwitterOAuth
+ class Client
+
+ # Returns the authenticated user's saved search queries.
+ def saved_searches
+ get("/saved_searches.json")
+ end
+
+ # Retrieve the data for a saved search owned by the authenticating user specified by the given id.
+ def get_saved_search(search_id)
+ get("/saved_searches/show/#{search_id}.json")
+ end
+
+ # Creates a saved search for the authenticated user.
+ def create_saved_search(query)
+ post("/saved_searches/create.json", :query => query)
+ end
+
+ def delete_saved_search(search_id)
+ post("/saved_searches/destroy/#{search_id}.json")
+ end
+
+ end
+end
View
10 lib/twitter_oauth/spam.rb
@@ -0,0 +1,10 @@
+module TwitterOAuth
+ class Client
+
+ # The user specified in the id is blocked by the authenticated user and reported as a spammer.
+ def report_spam(user)
+ post("/report_spam.json", :id => user)
+ end
+
+ end
+end
View
15 lib/twitter_oauth/trends.rb
@@ -6,5 +6,20 @@ def trends
get("/trends.json")
end
+ # Returns the locations that Twitter has trending topic information for.
+ # The response is an array of "locations" that encode the location's WOEID (a Yahoo! Where On Earth ID)
+ # and some other human-readable information such as a canonical name and country the location belongs in.
+ def trends_available
+ get("/trends/available.json")
+ end
+
+ # Returns the top 10 trending topics for a specific location Twitter has trending topic information for.
+ # The response is an array of "trend" objects that encode the name of the trending topic, the query
+ # parameter that can be used to search for the topic on Search, and the direct URL that can be issued against Search.
+ # This information is cached for five minutes, and therefore users are discouraged from querying these endpoints
+ # faster than once every five minutes. Global trends information is also available from this API by using a WOEID of 1.
+ def trends_for_location(woeid)
+ get("/trends/woeid.json")
+ end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.