How do I get the farm-id and server-id to display photo?

Topics: Developer Forum
Feb 5, 2010 at 3:39 PM

I am using flickr.net to upload photos to Flickr. I have it working fine and it is returning me a photoid.

The problem that I am having is trying to build up a url to display the photo.

Looking at the documentation here, I want to build up a link in the following format:

http://farm{farm-id}.static.flickr.com/{server-id}/{id}_{secret}_[mstb].jpg

I have the photoid, and secret, but how do I get the farm-id, and server-id using Flickr.net?

Coordinator
Feb 8, 2010 at 8:58 AM

The library does all this work for you. Once you have the Photo or PhotoInfo instance returned by one of the Flickr methods then simply use the SquareThumbnailUrl, ThumbnailUrl, SmallUrl, MediumUrl or LargeUrl properties.

 

Feb 8, 2010 at 12:31 PM

Thank you Samjudson. I can't instantiate a Photo object with just the PhotoId. What are the other required parameters? Is there anywhere that I can find examples of how to use this library?

Thanks,

Dan

Coordinator
Feb 8, 2010 at 3:10 PM

The easiest way if you have just the photo ID is to call Flickr.PhotosGetInfo.

How are you getting the photo ID?

Perhaps showing us a bit of your code would help.

Sam

Feb 11, 2010 at 4:14 AM
Here is how I am getting the PhotoId:

string
supportedExtensions = ConfigurationManager.AppSettings["flickrSupportedExt"]; string currentExtension = System.IO.Path.GetExtension(flUploadImage.FileName); //check if the uploaded file is with supported extension if (supportedExtensions.ToLower().IndexOf(currentExtension.ToLower()) > -1) { try { //login via key and secret FlickrNet.Flickr account = new FlickrNet.Flickr(ConfigurationManager.AppSettings["flickrApiKey"], ConfigurationManager.AppSettings["flickrApiSecret"], ConfigurationManager.AppSettings["flickrToken"]); //authentication is done and now we can upload photo string photoID = account.UploadPicture(flUploadImage.FileContent, txtTitle.Text, txtDescription.Text, txtTags.Text , 1, 1, 1, FlickrNet.ContentType.Photo, FlickrNet.SafetyLevel.None, FlickrNet.HiddenFromSearch.Visible); lblInfo.Text = photoID; } catch (Exception ex) { lblInfo.Text = ex.Message; } } else { lblInfo.Text = "File with extension \"" + currentExtension + "\" is not supported.<br/>The supported extensions are:" + supportedExtensions; }

 

 

 

Coordinator
Feb 11, 2010 at 7:23 AM

Yes, Flickr.PhotosGetInfo is your best bet I reckon:

PhotoInfo info = account.PhotosGetInfo(photoID);

lblInfo.Text = info.SmallUrl;