Archive for December, 2006

ObjectiveFlickr 0.9.2 (Ruby) in Sync with the New “farm id” Requirement

Friday, December 29th, 2006

Also posted in Flickr API Group.

The Ruby version of the ObjectiveFlickr library has been updated. Version 0.9.2 includes support for Flickr’s new "farm id", now required for newly uploaded photos since the format’s announcement.

Your old code will work without any change. If you also use this library’s helper functions that help you handle the photo information (a hash that stores photo id, server id, "secret", and the newly-added farm id), there should be no problem working with new photos too.

Other minor changes include some refactoring and deprecations that should lead to cleaner code and style. Documentation is also updated. Please refer to its release notes for details.

To install ObjectiveFlickr, simply use "gem install objectiveflickr" for the latest version. The Ruby version is hosted at http://rubyforge.org/projects/objectiveflickr.

The Objective-C version (hosted separately at http://code.google.com/p/objectiveflickr/) will be updated shortly. I’m refactoring part of its code so it may take another few days.

FlickrBooth uses ObjectiveFlickr

Wednesday, December 27th, 2006

Tristan O’Tierney has written a nifty PhotoBooth plug-in called FlickrBooth, and it uses ObjectiveFlickr. PhotoBooth is an Apple OS X application that makes use of the iSight camera (now built-in in all new Mac laptops) and take quick snapshots. With FlickrBooth, snapshots are also uploaded along the way, it’s just that easy.

It’s a cool plug-in, be sure to check it out from Tristan’s own homepage!

Another interesting note is that someone just made a mod to FlickrBooth so that it becomes 23hqbooth (so that the snapshots are uploaded to 23hq instead). It’s really not a mod on FlickrBooth, but on ObjectiveFlickr! The person who did it simply change the Flickr API endpoint settings in ObjectiveFlickr, recompliled it, and prepared his own copy. Just download his build and put it into FlickrBooth, and it’s morphed!

A great example of how both FlickrBooth and ObjectiveFlickr can be used and extended. Thanks guys!

ObjectiveFlickr 0.9.1 (Ruby)

Wednesday, December 13th, 2006

This is a minor release. Three class methods are added to FlickrInvocation so that creating FlickrInvocation instances is now easier. Call FlickrInvocation’s class method default_api_key, default_shared_secret and default_options once, and you don’t have to repeat yourself again:

FlickrInvocation.default_api_key '(your_api_key_here)'
FlickrInvocation.default_option :raise_exception_on_error => true

# create an instance, you can use e.g. @@f in your Model class
f = FlickrInvocation.new

Update 1: you can either put the above snippet (without the instance creation line) at the bottom of environment.rb of your Rails application, or just put the lines above in any of your model class.

Update 2: One of the perks of using the option :raise_exception_on_error is that if you have to check if the response block (instances of FlickrResponse) has any error. If you remember to supply with exception handlers (rescue blocks), you can always use what’s returned by the call. Plus if you make an mistake in retrieving what’s not in the returned hash, the exception handler can catch that for you too.

ObjectiveFlickr 0.9.0 in Objective-C

Monday, December 11th, 2006

I’ve finally made the long overdue packaging of the latest version of ObjectiveFlickr (ObjC version). Some highlights:

  • A new app that demos how to make use of Flickr search API and WebKit to display cool search results, in the tradition of this Ruby on Rails demo.
  • Complete documentation generated by header2doc
  • A pre-built, ready-to-use ObjectiveFlickr.framework in the distributed package.

There are still lots of things to be done. As this is an on-going project and as I’ve learned a lot from developing it, I’ll continue improving this framework. Plans include unit testing, synchronous calls (now that I’ve understood how Cocoa’s performSelectorOnMainThread: works–a trick that involves threading, run loop, and a conditional lock), more documentation work, and better demo apps.

Meanwhile, do let me know if there’s anything ObjectiveFlickr can help you better. Thanks for the support!

ObjectiveFlickr in Ruby

Monday, December 11th, 2006

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!