I’ve just released a brand spanking new version of the Flickr.Net API library.
The big things to note are that this version has over 150 unit tests to make sure it is working correctly. It also covers 100% of the Flickr API methods (there is a unit test that ensures this).
I’ve also sent some considerable time running Microsoft Code Analysis against the library to try to ensure that it meets most of the Microsoft guidelines on library design. This has resulted in some quite wide ranging changes, most noticeably to many of the class names in the Library. Most of these changes could have been avoided but I felt that it was better to get the library in a consistent and easy to understand position going forward than try to maintain a large segment of code just for backward compatibility reasons.
The main reason for the change was actually to do with a little Flickr method called flickr.photos.getFavorites. Previously the library had used XML serialization and the serialization attributes to handle converting the returned XML from Flickr into .Net object. However there was a huge clash between the flickr.photos.getInfo method, which returned a root element of <photo> and sub elements containing different bits of information about that photo and the flickr.photos.getFavourites method which also returned a root element of <photo> and sub elements of <person> which were the people who had favourited that photo.
One solution to this was to add a PersonCollection property to the PhotoInfo class, but this I felt would just add to the already growing confusion in other areas, such as when returning a list of Photosets the Photoset.PhotoCollection property would always be null – this is because PhotosetsGetList does not return any photos, but the Photoset class is used in more than one place so had to handle all scenarios.
So instead I had to develop a method of overriding the XML deserialization. I chose to do this by a combination of a custom Interface (IFlickrParsable) and the use of generics to handle the processing of the responses.
Changes
So, now instead of PhotosetsGetList returning a Photosets class, it returns a PhotosetCollection class. This class is a generic collection which can be iterated over using foreach etc. It no longer has a PhotoCollection property. Instead the PhotosetsGetPhoto method now returns a PhotosetPhotoCollection which is a collection of Photo class instances as you would expect.
string ApiKey = "ABCDEFG";
string UserId = "";
Flickr f = new Flickr(ApiKey);
PhotosetCollection photosets = f.PhotosetsGetList(UserId);
foreach(Photoset photoset in photosets)
{
PhotosetPhotoCollection photos = f.PhotosetsGetPhotos(photoset.PhotosetId);
// Do something with all the photos here.
}
Likewise there are a large number of other changes – most noticeably that the Photos class is now called the PhotoCollection class.
Beta
Due to the large number of breaking changes I’ve labelled this version a beta until such time as I have had chance to actually use it myself. I’m already underway moving my Flickr screensaver over to this library, and its improved support for the Flickr methods has saved a huge number of method calls in that already, so I’m hopeful this is only a good move.
Download the latest version of the Flickr.Net API Library from here: http://flickrnet.codeplex.com/
You can also report bugs and ask questions over there too.
Thanks for the updated release!
Is there a way to get a collection of galleries?
Thanks for your help in advance!
Mike
GalleriesGetList gets a list of galleries, and there are a set of methods to get a list of Collections, so I hope that answers your question.
Unfortunately Flickr have not provided a method for getting the photos of a gallery yet.
I saw ur sample(coding4fun) for uploading photos to flickr.
Is there a sample application to demonstrate how to download photos from flickr?