Using FlickrNetSilverlight with WP7 applications

Aug 13, 2010 at 1:23 AM
Edited Aug 13, 2010 at 1:25 AM

I have added flickrNetSilverlight as a reference in WP7 which works fine.

I was wondering if you have a basic sample working in WP7 as I am not sure what I might be doing wrong.  My first attempt was to mimic some of your samples

Flickr flickr = new Flickr("API_KEY","SHARED_KEY");
PhotoSearchOptions searchOptions = new PhotoSearchOptions();
searchOptions.Tags = "microsoft";
searchOptions.PerPage = 10;
 Photos microsoftPhotos = flickr.PhotosSearch(searchOptions);

When I create an instance of Flickr I am getting errors when I reference flickr (ie flickr.PhotosSearch(searchOptions) as well as searchOptions.

The application is also not picking them up other.

 

actual errors:

Error 5 'flickrTest.MainPage.searchOptions' is a 'field' but is used like a 'type' c:\Users\newshaggy\Documents\Visual Studio 2010\Projects\flickrTest\flickrTest\MainPage.xaml.cs 29 9 flickrTest

Error 2 Invalid token '=' in class, struct, or interface member declaration c:\Users\newshaggy\Documents\Visual Studio 2010\Projects\flickrTest\flickrTest\MainPage.xaml.cs 30 31 flickrTest


Coordinator
Aug 13, 2010 at 6:16 AM

If you have a PhotosSearch method then you have the wrong DLL, as the Silverlight version does not have that method.

A simple example would be something like this:

 

Flickr flickr = new Flickr("API_KEY","SHARED_KEY");
PhotoSearchOptions searchOptions = new PhotoSearchOptions();
searchOptions.Tags = "microsoft";
searchOptions.PerPage = 10;

flickr.PhotosSearchAsync(
    searchOptions,
    result =>
    {
        if( result.HasError )
        {
            // use result.Code  or result.Error 
            // to determine what the exception was.
        }
        else
        {
            Photos microsoftPhotos = result.Result;
            // Do something with the photos.
        }
    });

I hope that helps. We are working on a sample Silverlight app, and a sample WP7 app.