Go Picasa go is intended as library written in ruby to manipulate Picasa albums and photos in a easy way. The idea is to provide behaviors to ordinary objects so they can create, retrieve, update and delete albums and photos in a more object oritented way, lefting behind all the HTTP talk that was necessary previouly to interect with this service provided by Google.
This library was implemented based on the Protocol Guide version 2.0 of Picasa Web Albums Data API.
Go Picasa go is still under heavy development but it’s available for testing. We will be glad if you can do some tests and give us your feedback. Thank you.
gem install go-picasa-go
On the command line, run the user_class generator to create a file with the authentication token and other stuff you need:
go-picasa-go user_class YourUserClass google_user_id, google_password
After running the command above, a file called “your_user_class.rb” will be generated at the current folder you’re at. The google user id and google password are only necessary to generate the authentication token for further operations with Go-picasa-go. It’s also important for you to know that the password is only used on this single operation. All other operations executed by the gem uses only the authentication token generated.
user = YourUserClass.new
To create an album:
album = Picasa::DefaultAlbum.new album.user = user album.title = "Title" album.summary = "Summary" album.location = "Location" album.keywords = "Keyword, another keyword" album.access = 'private' # Other options: public, protected album.picasa_save # Returns true or false album.picasa_save! # Raise exception in case of not being able to save the album
To update that album:
album.title = "Updating the title" album.picasa_update # Returns true or false album.picasa_update! # Raise exception in case of not being able to update the album
To destroy an album:
album.picasa_destroy # Returns true or false album.picasa_destroy! # Raise exception in case of not being able to destroy the album
To retrieve all albums from an user:
user.albums
To retrieve one specific album
user.find_album album.picasa_id
To create a new photo:
photo = Picasa::DefaultPhoto.new photo.album = album photo.description = "Photo summary" photo.file = File.open 'path/photo.jpg' photo.picasa_save # Returns true or false photo.picasa_save! # Raise exception in case of not being able to save the photo
To update an existing photo:
photo.title = "Updating title" photo.description = "Updating summary" photo.file = File.open 'path/new_photo.jpg' photo.picasa_update # Returns true or false photo.picasa_update! # Raise exception in case of not being able to update the photo
To destroy an existing photo:
photo.picasa_destroy # Returns true or false photo.picasa_destroy! # Raise exception in case of not being able to delete the photo
To retrieve all photos from an album:
album.photos
To find an specific photo from an album:
album.find_photo photo.id
If you need your own classes to interact to Picasa you can do it like this:
class MyUser act_as_picasa_user has_many_picasa_albums :class_name => "MyAlbum" def picasa_id 'your_google_user_id' end def auth_token 'DQAAAHsAAAAdMyvdNfPg_iTFD-T_u6bBb-9Be...' end end class MyAlbum acts_as_picasa_album belongs_to_picasa_user :class_name => "MyUser" has_many_picasa_photos :class_name => "MyPhoto" end class MyPhoto acts_as_picasa_photo belongs_to_picasa_album :class_name => "MyAlbum" end
We provided this kind of configuration so your classes can interact with other frameworks like Rails and inherit from ActiveRecord::Base for example.
In the folder examples/rails-example there’s simple rails application that implements the CRUD of Album and Photo using Go-picasa-go. Enjoy!