Net::Flickr::People#find_by_user_id

2008 October 30
tags: ,
by robertor

…a short, random post…

It’s the end of the month, and I need to meet my self-imposed quota so that the archives have a link to October 2008. ;-)

After looking around at the different Ruby Flickr libraries, Net::Flickr seems to be the most active today. It’s undergoing some major refactoring for its next release. The current release is tagged 0.0.1 and Pre-Alpha. I think it was tagged this way to give people a warm fuzzy feeling when they use it on production apps. :-)

Anyway, 0.0.1 Pre-Alpha needs a lookup to find a person by user_id. There’s code in Net::Flickr::Person that does a lookup by user_id, but you need to know the person’s email address or username.

0.0.1 Pre-Alpha Net::Flickr::People#find_by_user_id

module Net; class Flickr
  class People
    # Looks up a Flickr user based on their user_id.
    #
    # See http://flickr.com/services/api/flickr.people.getInfo.html for
    # details.
    def find_by_user_id(user_id, args = {})
      args['user_id'] = user_id
      response = @flickr.request('flickr.people.getInfo', args)

      Person.new(@flickr, response.at('person'))
    end
  end
end; end

Based on the current code in SVN, the next release might need something like this:

module Net; class Flickr
  class People
    # Looks up a Flickr user based on their user_id.
    #
    # See http://flickr.com/services/api/flickr.people.getInfo.html for
    # details.
    def find_by_user_id(user_id, args = {})
      args['user_id'] = user_id
      response = Net::Flickr.instance().request('flickr.people.getInfo', args)

      Person.new(response.at('person'))
    end
  end
end; end
No comments yet

Leave a Reply

Note: You can use basic XHTML in your comments. Your email address will never be published.

Subscribe to this comment feed via RSS