Tuesday, June 05, 2007 at 6:17 PM
Posted by Greg Robbins, Mac Software EngineerMy parents enjoy it when I bring them printouts of my favorite photos, but the rest of my family and friends are happier just to get links to the pictures. With the Mac uploaders for Picasa Web Albums, it's quick and easy to put my photos on Google's servers.
But there's a lot more to share besides snapshots. Maybe you've created an avatar for your online world and you'd like to show your creativity to friends who live "outside." Or consider this: security cameras and webcams can capture suspicious activity. Those could go into a Picasa Web Album, and be monitored like any other RSS feed. Almost every Mac application can extend its reach by sharing online. And with Google Data APIs, there's no need for a specialized server. Any application can let you share your data with your Google Account.
Now that Picasa Web Albums has a Google data API, I've updated the open-source Objective-C Client Library to make it easy for developers to share photos from their applications. Here's what it looks like for a programmer adding the picture SunsetPhoto.jpg to the album "My Best Photos":
GDataServiceGooglePicasaWeb* service =
[[GDataServiceGooglePicasaWeb alloc] init];
[service setUserCredentialsWithUsername:@"my.account@gmail.com"
password:@"mypasswd"];
// get the URL for the album
NSURL *albumURL = [GDataServiceGooglePicasaWeb
picasaWebFeedURLForUserID:@"my.account" albumID:nil
albumName:@"MyBestPhotos" photoID:nil kind:nil access:nil];
// set a title and description for the new photo
GDataTextConstruct *title, *desc;
title = [GDataTextConstruct textConstructWithString:@"Sunset Photo"];
desc = [GDataTextConstruct textConstructWithString:@"A nice day"];
GDataEntryPhoto *newPhoto = [GDataEntryPhoto photoEntry];
[newPhoto setTitle:title];
[newPhoto setPhotoDescription:desc];
// attach the photo data
NSData *data = [NSData dataWithContentsOfFile:@"/SunsetPhoto.jpg"];
[newPhoto setPhotoData:data];
[newPhoto setPhotoMIMEType:@"image/jpeg"];
// now upload it
GDataServiceTicket *ticket;
ticket = [service fetchPicasaWebEntryByInsertingEntry:newPhoto
forFeedURL:albumURL
delegate:self
didFinishSelector:@selector(addPhotoTicket:finishedWithEntry:)
didFailSelector:@selector(addPhotoTicket:failedWithError:)];
The new library includes sample code that shows developers how to browse albums, add tags, display upload progress, and take advantage of the full Picasa Web Albums API. So now you can encourage the developer of your favorite application to make it easy and free for you to share your work online, too.