在iPhone上使用Objective C将图像上传到Picasa

时间:2011-07-21 18:43:49

标签: iphone objective-c api picasa

我想知道是否有人有任何他们用来将图片上传到Picasa的代码信息。我真的只需要代码来上传图像,我有一切工作来获取图像并查看它,但另一方面是给我一个问题。

Google并没有提供任何有关如何执行此操作的良好文档。非常感谢任何帮助,提前谢谢!

1 个答案:

答案 0 :(得分:1)

检查此代码:

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