2011-07-21 47 views
1

我想知道是否有人有任何關於他們用來上傳圖片到Picasa的代碼的信息。我真的只需要代碼來上傳圖片,我有一切工作來獲取圖片供稿並查看圖片,但以另一種方式給我一個問題。用iPhone上的Objective C將圖片上傳到Picasa

谷歌並沒有提供任何有關如何做到這一點的文檔。任何幫助將不勝感激,提前致謝!

回答

1

檢查這個代碼:

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

+0

我會檢查這個,讓你知道它是如何制定出來的,除了現在我的老闆要我用的Flickr做上傳照片之類的東西那。我寧願使用Picasa,但這不是我的決定。 :/ – MZimmerman6

+0

此代碼大部分工作,但我有一個問題得到一個錯誤,指出我沒有輸入photoID。爲了防止這種情況發生,我想我會做出一個。沒有這樣的運氣。任何建議 – MZimmerman6

+0

有人可以給我發送代碼。我無法啓動,因爲我得到的不是iOS的Mac支持代碼。另外,我不瞭解Google API的集成。 – Swati