Loading [MathJax]/extensions/tex2jax.js

2011-05-17

Picasaへ写真を投稿する

以前の、GooglePicasa APIを試してみたの続編で、JavaでPicasaに写真をアップロードするサンプルです。
  1. PicasawebService myService = new PicasawebService("example");  
  2. myService.setUserCredentials("<ここにユーザID>""<ここにパスワード>");  
  3.   
  4. URL albumPostUrl = new URL("http://picasaweb.google.com/data/feed/api/user/<ここにユーザID>/albumid/<ここにアルバムID>");  
  5. PhotoEntry myPhoto = new PhotoEntry();  
  6. myPhoto.setTitle(new PlainTextConstruct("ファイル名"));  
  7. myPhoto.setDescription(new PlainTextConstruct("タイトル"));  
  8. myPhoto.setClient("クライアント名");//ちょっとここは不明  
  9.   
  10. MediaFileSource myMedia = new MediaFileSource(new File("C:\\temp\\kiku.jpg"), "image/jpeg");  
  11. myPhoto.setMediaSource(myMedia);  
  12.   
  13. PhotoEntry returnedPhoto = myService.insert(albumPostUrl, myPhoto);  
最後のreturnedPhoto には、アップしたファイルのURLなどが格納されています。

0 件のコメント:

コメントを投稿