我想知道是否有人有任何用于将图像上传到 Picasa 的代码信息。我真的只需要上传图像的代码,我已经完成了获取图像源并查看它的所有工作,但是采用其他方式给我带来了问题。
Google 并没有真正提供任何好的文档来说明如何执行此操作。任何帮助将不胜感激。
检查此代码:
GDataServiceGooglePicasaWeb* service =
[[GDataServiceGooglePicasaWeb alloc] init];
[service setUserCredentialsWithUsername:@"[email protected]"
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:)];
来源:http://googlemac.blogspot.com/2007/06/picasa-web-albums-meets-google-data.html