smalltalk

Creating a Photo Album in Facebook from Smalltalk

May 14, 2009 17:43:22.167

After I uploaded some photos to Facebook earlier using iPhoto, I decided to see how hard the same operation would be from Smalltalk. Here's the code:


"Create an album, upload to it"
album := PhotoAlbum new.
album name: 'Annapolis Coulton Concert'.
album location: 'Annapolis, MD'.
album description: 'Jonathan Coulton concert with Paul and Storm at the RamsHead in Annapolis, MD'.
album visible: 'friends'.
returnAlbum := connection photosCreateAlbum: album.
returnAlbum := aPhotoAlbum

dir := '../images/coulton'.
files := dir asFilename directoryContents.
photos := files collect: [:each |
	| photo |
	photo := PhotoUpload new.
	photo caption: 'Coulton Concert in Annapolis'.
	photo aid: returnAlbum aid.
	photo filename: (dir asFilename construct: each) asString].
answers := connection photosUploadMultiple: photos.

You can see how wrapping a small UI on that would be pretty simple. Heck, most of the code is just creating the domain objects that are required for the calls :) The code is all in the public store, in FacebookBundle

Technorati Tags: ,

Comments

Small bug in there:

[Claus] May 15, 2009 12:23:36.744

Small bug:

returnAlbum is yet a Dictionary which does not understand 'aid', but does understand at: 'aid'.

 

Mmm

[ anonymous] May 15, 2009 12:40:55.668

Comment by anonymous

Not in the last version I published :)

 Share Tweet This
-->