OK so a project I'm working on now is using the flickr api to get pictures, so my team looked around the web for a good library for ruby and at last we found rflickr. Rflickr has very little documentation except for Max Dunn's tutorial witch I borrowed some from so here's how I did it
First create a new rails project:
%> rails myapp
%> cd myapp
Now lets make sure we have the latest version of the gem installed
%> sudo gem install rflickr
Make sure you install all of the required dependencies
Now we're ready to get started open the ruby console
%> script/console
Loading development environment.
now we make sure we require the flickr library
>> require 'flickr'
now set your api key and your shared secret
>>API_KEY = "your_api_key_here"
>>SHARED_SECRET = "your_secret_here"
now we start flickr up don't forget to include the path to flickr.cache
>>flickr = Flickr.new ("/tmp/flickr.cache", API_KEY, SHARED_SECRET)
now we get the frob,
>>flickr.auth.getFrob
and generate the login link.
>>flickr.auth.login_link('write')
now copy that link into your browser and allow it
Now all that's left to do is to get the token and cache the token
>>flickr.auth.getToken
>>flickr.auth.cache_token
Rock on now we're up and running...so we got this flickr think so ummm what can we do with it. Well lets try it on something simple shall we? First restart the console, then we just have a few steps instead of all of those steps all over again.
Set your api key and your secret
>>API_KEY = "your_api_key_here"
>>SHARED_SECRET = "your_secret_here"
Then load your environment and the token.
>>flickr = Flickr.new("/tmp/flickr.cache", API_KEY, SHARED_SECRET)
>>flickr.auth.token
Lets try a simple function first. Let's get a users tags.
>>flickr.tags.getListPhoto('269619243')
The rest of the api is straight forward. It's just like the flickr api. If you have any topics that you find interesting or want to learn about and I'll try to post them here. As always you can contact me at chrisprayingmantis@yahoo.com. I would love to hear from anyone who is reading this blog.
Saturday, January 13, 2007
The real guide for getting up and running with rflickr
Labels:
API,
Flickr,
Rflickr,
Ruby,
Ruby on Rails
Subscribe to:
Post Comments (Atom)
3 comments:
Hello, i've done the showing steps, but ruby fails:
ERR: Invalid frob (108)
/usr/lib/ruby/1.8/xmlrpc/client.rb:414:in `call': Invalid frob (XMLRPC::FaultException)
from /usr/lib/ruby/gems/1.8/gems/rflickr-2006.02.01/lib/flickr/base.rb:153:in `call_unauth_method'
from /usr/lib/ruby/gems/1.8/gems/rflickr-2006.02.01/lib/flickr/auth.rb:52:in `getToken'
from flickr_up_test.rb:20:in `initialize'
from flickr_up_test.rb:33
I don't understand this problem ! Please give me help :-(
I just got this work, try this :
after
flickr.auth.getFrob
get the auth_link again,
flickr.auth.login_link
=> “http://blahblahblah”
You would click on the ‘blahblahblah’ link to authorize the API usage.
then, get Token and save Token
irb(main) > flickr.auth.getToken
irc(main) > flickr.auth.cache_token
This works for me.
Post a Comment