我想知道是否有人有任何他们用来将图像上传到 Picasa 的代码信息。我真的只需要上传图片的代码,我已经完成了所有工作来获取图片提要并查看它,但是换一种方式给我带来了问题。
谷歌并没有真正提供任何关于如何做到这一点的好的文档。任何帮助将不胜感激,在此先感谢!
我想知道是否有人有任何他们用来将图像上传到 Picasa 的代码信息。我真的只需要上传图片的代码,我已经完成了所有工作来获取图片提要并查看它,但是换一种方式给我带来了问题。
谷歌并没有真正提供任何关于如何做到这一点的好的文档。任何帮助将不胜感激,在此先感谢!
检查此代码:
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:)];
资料来源:http: //googlemac.blogspot.com/2007/06/picasa-web-albums-meets-google-data.html