Get images from Flickr problem

Topics: Project Management Forum, User Forum
Feb 17, 2012 at 12:40 PM

Hi,

Im kind of new to this and had runned into some problems. Im trying to get images from a specific Flickr user but my application throws an error message.

This code is what i come up to yet.

 

    protected void Page_Load(object sender, EventArgs e)
    {
        PhotoRepeater.DataSource = RecentPhotos();
        PhotoRepeater.DataBind();
    }

    public static FlickrNet.PhotoCollection RecentPhotos()
    {
        FlickrNet.Flickr flickr = new FlickrNet.Flickr();
        flickr = new FlickrNet.Flickr("eb2dc2ad4b18cxxxxxxxxxxxxxxxxxxxxx", "a5a4c51xxxxxxx");
        FlickrNet.PhotoSearchOptions options = new FlickrNet.PhotoSearchOptions();
        //options.UserId = ConfigurationManager.AppSettings.Get("IPM.UK");
        options.UserId = "76185588@N08";
        options.PerPage = 20;
        options.Page = 1;
        options.SortOrder = FlickrNet.PhotoSearchSortOrder.DatePostedDesc;

        FlickrNet.Photos photos = flickr.PhotosSearch(options);

        if (photos.PhotoCollection == null)
            return new FlickrNet.Photo[0];
        else
            return photos.PhotoCollection;
    }

Coordinator
Feb 17, 2012 at 2:25 PM

That seems to be based on some very old code. PhotoSearch now returns a PhotoCollection instance, which is a collection of photos. 

Simply change it to the following should work:

return flickr.PhotoSearch(options);

Sam

Feb 17, 2012 at 2:59 PM

Thank you for the quick response Sam!

 

I tryed replacing the return code-snippet but without success. The code you gave me was underlined by red displaying this message:

"'FlickrNet.Flickr' does not contain a definition for 'PhotoSearch' and no extension method 'PhotoSearch' accepting a first argument of type 'FlickrNet.Flickr' could be found (are you missing a using directive or an assembly reference?)"

    protected void Page_Load(object sender, EventArgs e)
    {
        PhotoRepeater.DataSource = RecentPhotos();
        PhotoRepeater.DataBind();
    }

    public static FlickrNet.PhotoCollection RecentPhotos()
    {
        FlickrNet.Flickr flickr = new FlickrNet.Flickr();
        flickr = new FlickrNet.Flickr("eb2dc2ad4b18cxxxxxxxxxxxxxxxxxxxxx", "a5a4c51xxxxxxx");
        FlickrNet.PhotoSearchOptions options = new FlickrNet.PhotoSearchOptions();
        options.UserId = "76185588@N08";
        options.PerPage = 20;
        options.Page = 1;
        options.SortOrder = FlickrNet.PhotoSearchSortOrder.DatePostedDesc;

        FlickrNet.Photos photos = flickr.PhotosSearch(options);

        if (photos.PhotoCollection == null)
            return new FlickrNet.Photo[0];
        else
            return flickr.PhotoSearch(options);
    }

Coordinator
Feb 17, 2012 at 3:53 PM

I misspelt PhotosSearch(). That really shouldn't have been that hard to work out on your own.

Feb 17, 2012 at 4:33 PM
Edited Feb 17, 2012 at 4:34 PM

Very sorry about that. Im new to this.

When i run the application i get another error message,

"An invalid data source is being used for PhotoRepeater. A valid data source must implement either IListSource or IEnumerable."

I use the repeater-controller from the toolbox.

 

 

    protected void Page_Load(object sender, EventArgs e)
    {
        PhotoRepeater.DataSource = RecentPhotos();
        PhotoRepeater.DataBind();
    }

    public static FlickrNet.Photos RecentPhotos()
    {
        FlickrNet.Flickr flickr = new FlickrNet.Flickr();
        flickr = new FlickrNet.Flickr("eb2dc2ad4b18cc8cexxxxxxxxxx", "a5a4c51b8b4xxxxxxxxxx");
        FlickrNet.PhotoSearchOptions options = new FlickrNet.PhotoSearchOptions();
        //options.UserId = ConfigurationManager.AppSettings.Get("IPM.UK");
        //options.UserId = "76185588@N08";
        options.Tags = "blue";
        options.PerPage = 20;
        options.Page = 1;
        options.SortOrder = FlickrNet.PhotoSearchSortOrder.DatePostedDesc;

        FlickrNet.Photos photos = flickr.PhotosSearch(options);

        if (photos.PhotoCollection == null)
            return new FlickrNet.Photos();
        else
            return flickr.PhotosSearch(options);
    }

____________________________________________________________________________________________________________

<body>
    <form id="form1" runat="server">
    <div>
        <asp:Repeater ID="PhotoRepeater" runat="server">
        </asp:Repeater>
    </div>
    </form>
</body>

Thank you so much for the quick help!

 


Coordinator
Feb 18, 2012 at 6:08 PM

You still seem to be using a very old copy of the FlickrNet.dll. Please get the latest version from the download tab.