Getting More Than One Page

Create a PhotosSearchOptions object to set your search settings

C#
PhotoSearchOptions options = new PhotoSearchOptions();
options.UserId = "1234567@N01"; // Your NSID
options.PerPage = 100; // 100 is the default anyway


VB.Net
Dim options As New PhotoSearchOptions()
options.UserId = "1234567@N01"
options.PerPage = 100


Then return the first, second and third pages

C#
// The following returns the first set of photos
options.Page = 1; // page 1 is the default if Page is not set
PhotoCollection firstSet = flickr.PhotosSearch(options);
options.Page = 2;
PhotoCollection secondSet = flickr.PhotosSearch(options);
options.Page = 3;
PhotoCollection thirdSet = flickr.PhotosSearch(options);


VB.Net
' The following returns the first set of photos
options.Page = 1; // page 1 is the default if Page is not set
Dim firstSet As PhotoCollection = flickr.PhotosSearch(options);
options.Page = 2;
Dim secondSet As PhotoCollection = flickr.PhotosSearch(options);
options.Page = 3;
Dim thirdSet As PhotoCollection = flickr.PhotosSearch(options);


Finally, you can merge these photos into one photo collection

C#
List<Photo> mergedCollection = new List<Photo>();
mergedCollection.AddRange(firstSet);
mergedCollection.AddRange(secondSet);
mergedCollection.AddRange(thirdSet);

// And then look through the array of photos.
foreach( Photo p in mergedCollection)
{
    Console.WriteLine("Photo title is '" + p.Title + "'");
}


VB.Net
Dim  mergedCollection As New List(Of Photo)()
mergedCollection.AddRange(firstSet);
mergedCollection.AddRange(secondSet);
mergedCollection.AddRange(thirdSet);

' And then look through the array of photos.
For Each p As Photo In mergedCollection)
    Console.WriteLine("Photo title is '" & p.Title & "'")
Next

Last edited Mar 23, 2010 at 3:50 PM by samjudson, version 8

Comments

jmanning Apr 21, 2010 at 1:53 AM 
Seems a little odd that there isn't an API provided that just does this for you, like GetAllPhotos or whatever.

krisrickb Dec 9, 2009 at 6:28 PM 
The object from the first example looks to be called "PhotoSearchOptions" , not "PhotosSearchOptions". extra 's' in the example.