FavoritesGetPublicList() 공개 메소드

Gets the public favourites for a specified user.
This function difers from Flickr.FavoritesGetList(string) in that the user id is not optional.
public FavoritesGetPublicList ( string userId ) : Photos
userId string The is of the user whose favourites you wish to return.
리턴 Photos
예제 #1
0
        public List<Photo> Read(int page = 1)
        {
            var photos = new List<Photo>();
            var flickr = new FlickrNet.Flickr(_apiToken, _secretKey);
            
            PhotoCollection col = flickr.FavoritesGetPublicList(_userid, DateTime.Now.AddYears(-10), DateTime.Now,
                                                                PhotoSearchExtras.All, page, _perPage);

            foreach (FlickrNet.Photo item in col)
            {
                var author = new Author
                    {
                        Name = item.OwnerName,
                        ID = item.UserId,
                        URL = string.Format("https://www.flickr.com/photos/{0}/", item.UserId)
                    };
                photos.Add(new Photo
                    {
                        Title = item.Title,
                        URL = item.WebUrl,
                        Path = item.DoesLargeExist ? item.LargeUrl : item.MediumUrl,
                        PublishedDate = item.DateTaken,
                        Author = author
                    });
            }
            return photos;
        }
예제 #2
0
        private void FindUserButton_Click(object sender, EventArgs e)
        {
            // First page of the users photos
            // Sorted by interestingness

            Flickr flickr = new Flickr(ApiKey.Text);
            FoundUser user;
            try
            {
                user = flickr.PeopleFindByUserName(Username.Text);
                OutputTextbox.Text = "User Id = " + user.UserId + "\r\n" + "Username = "******"\r\n";
            }
            catch (FlickrException ex)
            {
                OutputTextbox.Text = ex.Message;
                return;
            }

            PhotoSearchOptions userSearch = new PhotoSearchOptions();
            userSearch.UserId = user.UserId;
            userSearch.SortOrder = PhotoSearchSortOrder.InterestingnessDescending;
            PhotoCollection usersPhotos = flickr.PhotosSearch(userSearch);
            // Get users contacts
            ContactCollection contacts = flickr.ContactsGetPublicList(user.UserId);
            // Get first page of a users favorites
            PhotoCollection usersFavoritePhotos = flickr.FavoritesGetPublicList(user.UserId);
            // Get a list of the users groups
            //PublicGroupInfoCollection usersGroups = flickr.PeopleGetPublicGroups(user.UserId);

            int i = 0;
            foreach (Contact contact in contacts)
            {
                OutputTextbox.Text += "Contact " + contact.UserName + "\r\n";
                if (i++ > 10) break; // only list the first 10
            }

            i = 0;
            //foreach (PublicGroupInfo group in usersGroups)
            //{
            //    OutputTextbox.Text += "Group " + group.GroupName + "\r\n";
            //    if (i++ > 10) break; // only list the first 10
            //}

            i = 0;
            foreach (Photo photo in usersPhotos)
            {
                OutputTextbox.Text += "Interesting photo title is " + photo.Title + " " + photo.WebUrl + "\r\n";
                if (i++ > 10) break; // only list the first 10
            }

            i = 0;
            foreach (Photo photo in usersFavoritePhotos)
            {
                OutputTextbox.Text += "Favourite photo title is " + photo.Title + " " + photo.WebUrl + "\r\n";
                if (i++ > 10) break; // only list the first 10
            }
        }