Exemple #1
0
        internal static MediaItemList CreateFromXmlNodeList(XmlNodeList mediaNodeList)
        {
            MediaItemList mediaList = new MediaItemList();

            foreach (XmlNode mediaNode in mediaNodeList)
            {
                mediaList.Add(MediaItem.CreateFromXmlNode(mediaNode));
            }

            return(mediaList);
        }
Exemple #2
0
        public MediaItemList GetFeaturedMedia()
        {
            string relativePath = GenerateRelativeFeaturedUrl();

            QueryParameterList paramaters = new QueryParameterList();

            paramaters.Add(new QueryParameter(_format, "xml"));

            string getFeaturedMediaUrl = OAuth.GenerateURL(_apiUrl, relativePath, _featuredMediaMethod, Token, paramaters);

            XmlResponseMessage getFeaturedMediaResponseMessage = GetXmlResponseMessageFromUrl(getFeaturedMediaUrl, _featuredMediaMethod);

            return(MediaItemList.CreateFromXmlResponseMessage(getFeaturedMediaResponseMessage));
        }
        public MediaItemList GetUsersRecentMedia(string username, MediaType type, int page, int perPage)
        {
            string relativePath = GenerateRelativeUserSearchUrl(username);

            QueryParameterList paramaters = new QueryParameterList();

            paramaters.Add(new QueryParameter(_format, "xml"));
            paramaters.Add(new QueryParameter(_type, type.ToString().ToLower()));
            paramaters.Add(new QueryParameter(_page, page.ToString()));
            paramaters.Add(new QueryParameter(_perpage, perPage.ToString()));

            string getUsersRecentMediaUrl = OAuth.GenerateURL(ApiUrl, relativePath, _getUserMediaMethod, Token, paramaters);

            XmlResponseMessage getUsersRecentMediaResponseMessage = GetXmlResponseMessageFromUrl(getUsersRecentMediaUrl, _getUserMediaMethod);

            return(MediaItemList.CreateFromXmlResponseMessage(getUsersRecentMediaResponseMessage));
        }
Exemple #4
0
        public MediaItemList GetRelatedMedia(MediaItem mediaItem, int num, MediaType mediaType)
        {
            string relativePath = GenerateRelativeRelatedMediaUrl(mediaItem.Url);

            QueryParameterList paramaters = new QueryParameterList();

            paramaters.Add(new QueryParameter(_format, "xml"));
            paramaters.Add(new QueryParameter(_num, num.ToString()));

            string type = mediaType == MediaType.Image ? "images" : "videos";

            paramaters.Add(new QueryParameter(_type, type));

            string getRelatedMediaUrl = OAuth.GenerateURL(ApiUrl, relativePath, _getRelatedMediaMethod, Token, paramaters);

            XmlResponseMessage getRelatedMediaResponseMessage = GetXmlResponseMessageFromUrl(getRelatedMediaUrl, _getRelatedMediaMethod);

            return(MediaItemList.CreateFromXmlNodeList(getRelatedMediaResponseMessage.ResponseXml.SelectNodes("descendant::media")));
        }
        public MediaItemList GetUsersMediaWithTag(string username, string tagname, int page, int perPage)
        {
            if (string.IsNullOrEmpty(tagname))
            {
                throw new PhotobucketApiException("tagname is null");
            }

            string relativePath = GenerateRelativeUsersMediaWithTagUrl(username, tagname);

            QueryParameterList paramaters = new QueryParameterList();

            paramaters.Add(new QueryParameter(_format, "xml"));
            paramaters.Add(new QueryParameter(_page, page.ToString()));
            paramaters.Add(new QueryParameter(_perpage, perPage.ToString()));

            string getUsersMediaWithTagTagsUrl = OAuth.GenerateURL(ApiUrl, relativePath, _getUsersMediaTagsMethod, Token, paramaters);

            XmlResponseMessage getUsersMediaWithTagResponseMessage = GetXmlResponseMessageFromUrl(getUsersMediaWithTagTagsUrl, _getUsersMediaTagsMethod);

            return(MediaItemList.CreateFromXmlResponseMessage(getUsersMediaWithTagResponseMessage));
        }
Exemple #6
0
        public MediaItemList SearchMedia(string query, int num, int perpage, int page, int offset, int secondaryperpage, string type, bool recentFirst)
        {
            string relativePath = GenerateRelativeSearchUrl(query);

            QueryParameterList paramaters = new QueryParameterList();

            paramaters.Add(new QueryParameter(_format, "xml"));
            paramaters.Add(new QueryParameter(_num, num.ToString()));
            paramaters.Add(new QueryParameter(_perpage, perpage.ToString()));
            paramaters.Add(new QueryParameter(_page, page.ToString()));
            paramaters.Add(new QueryParameter(_offset, offset.ToString()));
            paramaters.Add(new QueryParameter(_secondaryperpage, secondaryperpage.ToString()));
            paramaters.Add(new QueryParameter(_type, type));
            paramaters.Add(new QueryParameter(_recentfirst, recentFirst ? "1" : "0"));

            string searchMediaUrl = OAuth.GenerateURL(_apiUrl, relativePath, _searchMediaMethod, Token, paramaters);

            XmlResponseMessage searchMediaResponseMessage = GetXmlResponseMessageFromUrl(searchMediaUrl, _searchMediaMethod);

            return(MediaItemList.CreateFromXmlResponseMessage(searchMediaResponseMessage));
        }
        /// <summary>
        /// Get all the users media of a specific type and number perPage
        /// </summary>
        /// <param name="user"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        public MediaItemList GetAllUsersMedia(string username, MediaType type, int perPage)
        {
            MediaItemList mediaList = new MediaItemList();

            int  curPageNum     = 0;
            bool stillMoreToGet = true;

            while (stillMoreToGet)
            {
                curPageNum++;

                MediaItemList curPageMediaList = GetUsersRecentMedia(username, type, curPageNum, perPage);

                mediaList.AddRange(curPageMediaList);

                if (curPageMediaList.Count < perPage)
                {
                    stillMoreToGet = false;
                }
            }

            return(mediaList);
        }
        public MediaItemList GetAllUsersMediaWithTag(string username, MediaTag mediaTag)
        {
            MediaItemList mediaList = new MediaItemList();

            int  curPageNum     = 0;
            bool stillMoreToGet = true;

            while (stillMoreToGet)
            {
                curPageNum++;

                MediaItemList curPageMediaList = GetUsersMediaWithTag(username, mediaTag.Name, curPageNum, 200);

                mediaList.AddRange(curPageMediaList);

                if (curPageMediaList.Count < 200)
                {
                    stillMoreToGet = false;
                }
            }

            return(mediaList);
        }