public List <GooglePhotosAlbumInfo> GetAlbumList() { if (!CheckAuthorization()) { return(null); } List <GooglePhotosAlbumInfo> albumList = new List <GooglePhotosAlbumInfo>(); string response = SendRequest(HttpMethod.GET, "https://picasaweb.google.com/data/feed/api/user/default", headers: GetAuthHeaders()); if (!string.IsNullOrEmpty(response)) { XDocument xd = XDocument.Parse(response); if (xd != null) { foreach (XElement entry in xd.Descendants(AtomNS + "entry")) { GooglePhotosAlbumInfo album = new GooglePhotosAlbumInfo(); album.ID = entry.GetElementValue(GPhotoNS + "id"); album.Name = entry.GetElementValue(AtomNS + "title"); album.Summary = entry.GetElementValue(AtomNS + "summary"); albumList.Add(album); } } } return(albumList); }
public List <GooglePhotosAlbumInfo> GetAlbumList() { if (!CheckAuthorization()) { return(null); } List <GooglePhotosAlbumInfo> albumList = new List <GooglePhotosAlbumInfo>(); Dictionary <string, string> albumListArgs = new Dictionary <string, string> { { "excludeNonAppCreatedData", "true" }, { "fields", "albums(id,title,shareInfo),nextPageToken" } }; string pageToken = ""; do { albumListArgs["pageToken"] = pageToken; string response = SendRequest(HttpMethod.GET, "https://photoslibrary.googleapis.com/v1/albums", albumListArgs, GoogleAuth.GetAuthHeaders()); pageToken = ""; if (!string.IsNullOrEmpty(response)) { GooglePhotosAlbums albumsResponse = JsonConvert.DeserializeObject <GooglePhotosAlbums>(response); if (albumsResponse.albums != null) { foreach (GooglePhotosAlbum album in albumsResponse.albums) { GooglePhotosAlbumInfo AlbumInfo = new GooglePhotosAlbumInfo { ID = album.id, Name = album.title }; if (album.shareInfo == null) { albumList.Add(AlbumInfo); } } } pageToken = albumsResponse.nextPageToken; } }while (!string.IsNullOrEmpty(pageToken)); return(albumList); }