Пример #1
0
        /// <summary>
        /// Returns a list of tags 'related' to the given tag, based on clustered usage analysis.
        /// </summary>
        /// <param name="tag">The tag to fetch related tags for.</param>
        /// <returns>An array of <see cref="Tag"/> objects.</returns>
        public Tag[] TagsGetRelated(string tag)
        {
            Hashtable parameters = new Hashtable();
            parameters.Add("method", "flickr.tags.getRelated");
            parameters.Add("api_key", _apiKey);
            parameters.Add("tag", tag);

            FlickrNet.Response response = GetResponseCache(parameters);

            if( response.Status == ResponseStatus.OK )
            {
                XmlNodeList nodes = response.AllElements[0].SelectNodes("//tag");
                Tag[] tags = new Tag[nodes.Count];
                for(int i = 0; i < tags.Length; i++)
                {
                    tags[i] = new Tag(nodes[i]);
                }
                return tags;
            }
            else
            {
                throw new FlickrException(response.Error);
            }
        }
Пример #2
0
        /// <summary>
        /// Get the popular tags for a given user (or the currently logged in user).
        /// </summary>
        /// <param name="userId">The NSID of the user to fetch the tag list for. If this argument is not specified, the currently logged in user (if any) is assumed.</param>
        /// <param name="count">Number of popular tags to return. defaults to 10 when this argument is not present.</param>
        /// <returns>An array of <see cref="Tag"/> objects.</returns>
        public Tag[] TagsGetListUserPopular(string userId, long count)
        {
            Hashtable parameters = new Hashtable();
            parameters.Add("method", "flickr.tags.getListUserPopular");
            if( userId != null ) parameters.Add("user_id", userId);
            if( count > 0 ) parameters.Add("count", count.ToString());

            FlickrNet.Response response = GetResponseCache(parameters);

            if( response.Status == ResponseStatus.OK )
            {
                XmlNodeList nodes = response.AllElements[0].SelectNodes("//tag");
                Tag[] tags = new Tag[nodes.Count];
                for(int i = 0; i < tags.Length; i++)
                {
                    tags[i] = new Tag(nodes[i]);
                }
                return tags;
            }
            else
            {
                throw new FlickrException(response.Error);
            }
        }