Sha256: 4beaa128bde930915068399c7fb8f475bf3a5be9a15c5a7b38876011648fd5bf
Contents?: true
Size: 1.31 KB
Versions: 9
Compression:
Stored size: 1.31 KB
Contents
class Twitter::Client @@GRAPH_URIS = { :friends => '/friends/ids', :followers => '/followers/ids', } # Provides access to the Twitter Social Graphing API. # # You can retrieve the full graph of a user's friends or followers in one method call. # # <tt>action</tt> can be any of the following values: # * <tt>:friends</tt> - retrieves ids of all friends of a given user. # * <tt>:followers</tt> - retrieves ids of all followers of a given user. # # The <tt>value</tt> must be either the user screen name, integer unique user ID or Twitter::User # object representation. # # Examples: # screen_name = 'dictionary' # client.graph(:friends, 'dictionary') # client.graph(:followers, 'dictionary') # id = 1260061 # client.graph(:friends, id) # client.graph(:followers, id) # user = Twitter::User.find(id, client) # client.graph(:friends, user) # client.graph(:followers, user) def graph(action, value = nil) raise ArgumentError, "Invalid friend action provided: #{action}" unless @@GRAPH_URIS.keys.member?(action) id = value.to_i unless value.nil? || value.is_a?(String) id ||= value id ||= @login uri = "#{@@GRAPH_URIS[action]}.json" response = http_connect {|conn| create_http_get_request(uri, :id => id) } JSON.parse(response.body) end end
Version data entries
9 entries across 9 versions & 8 rubygems