ObjectiveFlickr in Ruby

I have created another Flickr API library under the same name, this time in Ruby.

The Ruby version of ObjectiveFlickr is an ultra lightweight Flickr API libray that currently does only one thing: making Flickr API calls. It leverages the fact that Flickr now provides JSON as one of the repsonse data formats. JSON makes it easy to manage Flickr return data, since we don’t need to create different Ruby classes now–we simply convert back the returned JSON string into Ruby hash/array objects, which are already well structured.

To install ObjectiveFlickr as a Ruby gem, use the following command:

gem install objectiveflickr --include-dependencies

The document will be automatically prepared by gem’s installer. Currently there are only two classes: FlickrInvocation and FlickrResponse. Simply create a FlickrInvocation instance with your API key and shared secret, and start making Flickr API calls, and extract the returned data from the FlickrResponse instance. For example, this code snippets returns 10 square photos (75×75) with the tag “flower”:

require 'rubygems'
require 'objectiveflickr'

f = FlickrInvocation.new('bf67a649fffb210651334a09b92df02e')
r = f.call("flickr.photos.search", :tags => "flowers", :per_page => 10)

if r.ok?
  for p in r["photos"]["photo"]
    p[:size] = "s"
    puts f.photo_url(p)
  end
end

I’ll continue working on both libraries (ObjC and Ruby) so that they can be helpful in making Flickr apps. Meanwhile, feel free to comment or let me know how ObjectiveFlickr can help you better. Thanks!

Leave a Reply