- Google Data API Access Control Library
- Google Data API Core Library
- Google Data API Extansions Library
- Google Data API Picasa Library
這個範例輸入 帳號、密碼及 AlbumUri 就可以取得 在這個相簿裡的 所有的photo 資料
註1、 AlbumUri 可以見上一篇 取得的 FeedUri
註2、 entry.Content.AbsoluteUri 就是實際存放相片的位址
/**
* @Name GetPhotoListInAlbum
*
* Get album list from the picasa web album
*
* @param Account [in] - the google accpount
* @param Password [in] - the google accpount's password
* @param AlbumUri [in] - the google picasa web album uri
*
*/
public void GetPhotoListInAlbum(string Account, string Password, string AlbumUri)
{
/// Set Service
PicasaService service = new PicasaService("Get_Album_List");
/// Set Account and Password
service.setUserCredentials(Account, Password);
/// Set Query
PhotoQuery query = new PhotoQuery(AlbumUri);
/// Set proxy
GDataRequestFactory requestFactory = (GDataRequestFactory)service.RequestFactory;
IWebProxy iProxy = WebRequest.DefaultWebProxy;
WebProxy myProxy = new WebProxy(iProxy.GetProxy(query.Uri));
///potentially, setup credentials on the proxy here
myProxy.Credentials = CredentialCache.DefaultCredentials;
myProxy.UseDefaultCredentials = true;
requestFactory.Proxy = myProxy;
/// Get feed
PicasaFeed feed = service.Query(query);
/// Get Album count
int count = feed.Entries.Count;
Console.WriteLine(count);
foreach (PicasaEntry entry in feed.Entries)
{
/// Get album title
string title = entry.Title.Text;
Console.WriteLine(title);
/// Get the image uri
string uri = entry.Content.AbsoluteUri;
Console.WriteLine(uri);
}
}
沒有留言:
張貼留言