Beispiel #1
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));
        }
Beispiel #2
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));
        }
      public bool ValidateUserToken(UserToken userToken)
      {
         string relativePath = GenerateRelativeUserUrl( userToken.Username );

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

         string validateUserUrl = OAuth.GenerateURL( userToken.UserApi , relativePath, _getUserMethod, userToken, paramaters );

         try
         {
            XmlResponseMessage getUserResponseMessage = GetXmlResponseMessageFromUrl( validateUserUrl, _getUserMethod );
            return true;
         }
         catch (PhotobucketApiException apiEx)
         {
            if (apiEx.ErrorCode == ErrorCode.CouldNotGet)
            {
               return false;
            }
            throw;
         }
      }