Search code examples
c#.netflickr

How can I retrieve Original URL photo with Flickr .NET API?


My code is:

FlickrNet.Flickr flickr = new FlickrNet.Flickr(apiKey, shardSecret);
FlickrNet.Flickr.CacheDisabled = true;

PhotoCollection photos = flickr.PeopleGetPublicPhotos(flickrUser);

linkPhoto = "http://farm" + photo.Farm + ".staticflickr.com/" + photo.Server + "/" + photo.PhotoId + "_" + photo.OriginalSecret + "_o."+photo.OriginalFormat;

but seems that photo.OriginalSecret and photo.OriginalFormat returns an empty string? Also tried with photo.OriginalUrl but is the same : empty string? Where am I wrong?


Solution

  • Use these options too:

            options.Extras = PhotoSearchExtras.OriginalFormat;
    

    This will make Flickr include the original URL in all cases, where you're allowed to see it. This is especially handy when you otherwise would use the LargeURL, as there're photos that just are not big enough to have a largeURL, and in that case Flickr will give you a langeURL that points to a "This Image is currently not available" picture.

    Then, if you want to find the "biggest version" of an image, you can do something like this:

    public string BiggestVersionUrl()
        {
            // find biggest version for downloading later
            string BiggestVersionUrl1 = string.Empty;
            var p = this.Photo;
            if (!string.IsNullOrEmpty(p.OriginalUrl))
                BiggestVersionUrl1 = p.OriginalUrl;
            else if (!string.IsNullOrEmpty(p.LargeUrl))
                BiggestVersionUrl1 = p.LargeUrl;
            else if (!string.IsNullOrEmpty(p.MediumUrl))
                BiggestVersionUrl1 = p.MediumUrl;
            else if (!string.IsNullOrEmpty(p.SmallUrl))
                BiggestVersionUrl1 = p.SmallUrl;
            return BiggestVersionUrl1;
        }