Crash893
Crash893

Reputation: 11702

download random image from flickr using keyword

I noticed this code when i was playing around with smallbasic showing it to a freind that it has a built in option to download a image from fliker based on a keyword

I was wondering if someone had an example in C# of doing this so that i can get an idea of how to use the api.

Upvotes: 0

Views: 2963

Answers (2)

Crash893
Crash893

Reputation: 11702

private void button1_Click(object sender, EventArgs e)
{
    string apikey = "3f8554b23a5we2fe2c7asdg80agnkdm9cedag415f34d9fb";
    Flickr F = new Flickr(apikey);


    // Example 2
    PhotoSearchOptions searchOptions = new PhotoSearchOptions();
    searchOptions.Tags = textBox1.Text;
    searchOptions.PerPage = 100;
    Photos microsoftPhotos = F.PhotosSearch(searchOptions);

    // Example 3
    searchOptions.Page = 2;
    Photos microsoftPhotos2 = F.PhotosSearch(searchOptions);
    searchOptions.Page = 3;
    Photos microsoftPhotos3 = F.PhotosSearch(searchOptions);

    // Eample 4
    PhotoCollection allPhotos = microsoftPhotos.PhotoCollection;
    allPhotos.AddRange(microsoftPhotos2.PhotoCollection);
    allPhotos.AddRange(microsoftPhotos3.PhotoCollection);


    progressBar1.Maximum = allPhotos.Count;
    progressBar1.Value = 0;


    foreach (Photo p in allPhotos)
    {
        pictureBox1.Image = Image.FromStream(F.DownloadPicture(p.MediumUrl));

        this.Refresh();

        progressBar1.Value++;
    }
}

Upvotes: 2

BFree
BFree

Reputation: 103740

I've never messed with Flickr's API, but here's a link I found that seems like it would be pretty helpful:

http://blogs.msdn.com/coding4fun/archive/2006/11/22/1126978.aspx

Upvotes: 2

Related Questions