예제 #1
0
        /// <summary>
        /// List the photos with the most views, comments or favorites.
        /// </summary>
        /// <param name="date">Stats will be returned for this date.
        /// A day according to Flickr Stats starts at midnight GMT for all users,
        /// and timestamps will automatically be rounded down to the start of the day.
        /// If no date is provided, all time view counts will be returned.</param>
        /// <param name="sort">The order in which to sort returned photos.
        /// Defaults to views. The possible values are views, comments and favorites. </param>
        /// <param name="page">The page of results to return.
        /// If this argument is omitted, it defaults to 1.</param>
        /// <param name="perPage">Number of photos to return per page.
        /// If this argument is omitted, it defaults to 25. The maximum allowed value is 100.</param>
        /// <param name="callback">Callback method to call upon return of the response from Flickr.</param>
        public void StatsGetPopularPhotosAsync(DateTime date, PopularitySort sort, int page, int perPage,
                                               Action <TwentyThreeResult <PopularPhotoCollection> > callback)
        {
            CheckRequiresAuthentication();

            var parameters = new Dictionary <string, string>();

            parameters.Add("method", "flickr.stats.getPopularPhotos");
            if (date != DateTime.MinValue)
            {
                parameters.Add("date", UtilityMethods.DateToUnixTimestamp(date));
            }
            if (sort != PopularitySort.None)
            {
                parameters.Add("sort", UtilityMethods.SortOrderToString(sort));
            }
            if (page > 0)
            {
                parameters.Add("page", page.ToString(System.Globalization.NumberFormatInfo.InvariantInfo));
            }
            if (perPage > 0)
            {
                parameters.Add("per_page", perPage.ToString(System.Globalization.NumberFormatInfo.InvariantInfo));
            }

            GetResponseAsync <PopularPhotoCollection>(parameters, callback);
        }