public BloggerWrapper(Settings settings, User user) { if (settings == null) throw new ArgumentNullException("settings"); if (user == null) throw new ArgumentNullException("user"); Settings = settings; User = user; BloggerService = new Service("blogger", "BlogMyFlickr") { Credentials = new GDataCredentials(settings.BloggerUserName, settings.BloggerPassword) }; GDataGAuthRequestFactory factory = (GDataGAuthRequestFactory)BloggerService.RequestFactory; factory.AccountType = "GOOGLE"; }
public Model.PhotoCollection LoadLatestPhotos(User user) { if (user == null) throw new ArgumentNullException("user"); PhotoSearchOptions searchOptions = new PhotoSearchOptions(user.Id); Model.PhotoCollection photoCollection = new Model.PhotoCollection(); foreach (FlickrNet.Photo photo in Flickr.PhotosSearch(searchOptions)) { photoCollection.Add(new Model.Photo { Id = photo.PhotoId, SourceUrl = photo.LargeUrl, SquareThumbnailUrl = photo.SquareThumbnailUrl, Title = photo.Title }); } return photoCollection; }
private static string GenerateContent(Photo photo, User user) { string photoHref = String.Format("{0}{1}", user.PhotosUrl, photo.Id); string photoTitle = String.Format("{0} by {1}, on Flickr", photo.Title, user.Username); string photoSrc = photo.SourceUrl; string photoCaption = String.Format( "{0}, {1}s, f/{2}, ISO-{3}, {4} @ {5}", photo.Exif.Model, photo.Exif.Exposure, photo.Exif.Aperture, photo.Exif.IsoSpeed, photo.Exif.LensDetails, photo.Exif.FocalLength); const string content = @"<table cellpadding=""0"" cellspacing=""0"" class=""tr-caption-container"" style=""margin-left: auto; margin-right: auto; text-align: center;""><tbody><tr><td style=""text-align: center;""><a href=""{0}"" style=""clear: right; margin-bottom: 1em; margin-left: auto; margin-right: auto;"" title=""{1}""><img alt=""{2}"" height=""{3}"" src=""{4}"" width=""{5}"" /></a></td></tr><tr><td class=""tr-caption"" style=""text-align: center;"">{6}</td></tr></tbody></table><br/>{7}"; return String.Format(content, photoHref, photoTitle, photo.Title, photo.PhotoHeight("Medium 640"), photoSrc, photo.PhotoWidth("Medium 640"), photoCaption, photo.PhotoDescriptionInHtml()); }