Unknown user (2) error for a valid user name?

Topics: User Forum
Feb 6, 2010 at 9:04 PM

Hi,

I have the following piece of code in my toy project:

string useremail = "validuseremail@flickr.com";

Flickr flickrRequest = new Flickr(Options.FlickrAPIKey, Options.FlickrAPISecret);
FoundUser userResults;
userResults = flickrRequest.PeopleFindByEmail(useremail);

Console.WriteLine("{0} username with {1} userID found for email {2}", userResults.Username, userResults.UserId, useremail);
                
PhotoSearchOptions flickrSearchOptions = new PhotoSearchOptions(userResults.Username);
Photos flickrPhotos = flickrRequest.PhotosSearch(flickrSearchOptions);

Console.WriteLine("{0} total results from Flickr for {1}", flickrPhotos.TotalPhotos, userResults.Username);   

I'm using a mock email address in the code posted here, but when I execute this with a valid Flickr user's email here is what happens:

  1. The Flickr user is found by the PeopleFindByEmail call
  2. The PhotosSearch call says that the user name, which I found earlier with the PeopleFindByEmail call, is an unknown user.

What's the issue here? Is this a bug with the API or is something wrong with my code?

Feb 6, 2010 at 9:09 PM

I'm an idiot - I just realized that I'm passing the username and not the user ID to the function. Doh!

The code should really look like this

string useremail = "validuseremail@flickr.com";

Flickr flickrRequest = new Flickr(Options.FlickrAPIKey, Options.FlickrAPISecret);
FoundUser userResults;
userResults = flickrRequest.PeopleFindByEmail(useremail);

Console.WriteLine("{0} username with {1} userID found for email {2}", userResults.Username, userResults.UserId, useremail);
                
PhotoSearchOptions flickrSearchOptions = new PhotoSearchOptions(userResults.UserId);
Photos flickrPhotos = flickrRequest.PhotosSearch(flickrSearchOptions);

Console.WriteLine("{0} total results from Flickr for {1}", flickrPhotos.TotalPhotos, userResults.Username);   
Coordinator
Feb 8, 2010 at 8:46 AM

So this is working fine now?

Sam

Feb 8, 2010 at 9:48 PM

Yep, working just fine.