コード例 #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));
        }
コード例 #2
0
        /// <summary>
        /// Get the User object that represents the user currently logged on
        /// </summary>
        /// <returns></returns>
        private User GetUser(string username)
        {
            string relativePath = GenerateRelativeUserUrl(username);

            QueryParameterList paramaters = new QueryParameterList( );

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

            string getUserUrl = OAuth.GenerateURL(ApiUrl, relativePath, _getUserMethod, Token, paramaters);

            XmlResponseMessage getUserResponseMessage = GetXmlResponseMessageFromUrl(getUserUrl, _getUserMethod);

            return(new User(getUserResponseMessage.ResponseXml));
        }
コード例 #3
0
        public UserUrls GetUsersUrls(string username)
        {
            string relativePath = GenerateRelativeUserUrl(username);

            QueryParameterList paramaters = new QueryParameterList();

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

            string getUsersUrlsUrl = OAuth.GenerateURL(ApiUrl, relativePath, _getUsersUrlMethod, Token, paramaters);

            XmlResponseMessage getUsersUrlsResponseMessage = GetXmlResponseMessageFromUrl(getUsersUrlsUrl, _getUsersUrlMethod);

            return(UserUrls.CreateFromXmlResponseMessage(getUsersUrlsResponseMessage));
        }
コード例 #4
0
        public void DeleteMediaDescription(ref MediaItem mediaItem)
        {
            string relativePath = GenerateRelativeMediaDescriptionUrl(mediaItem.Url);

            QueryParameterList paramaters = new QueryParameterList();

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

            string deleteMediaDescriptionUrl = OAuth.GenerateURL(ApiUrl, relativePath, _deleteMediaDescriptionMethod, Token, paramaters);

            XmlResponseMessage deleteMediaDescriptionResponseMessage = GetXmlResponseMessageFromUrl(deleteMediaDescriptionUrl, _deleteMediaDescriptionMethod);

            mediaItem.Description = String.Empty;
        }
コード例 #5
0
        private XmlDocument GetMediaLinks(MediaItem mediaItem)
        {
            string relativePath = GenerateRelativeMediaLinksUrl(mediaItem.Url);

            QueryParameterList paramaters = new QueryParameterList();

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

            string getMediaLinksUrl = OAuth.GenerateURL(ApiUrl, relativePath, _getMediaLinksMethod, Token, paramaters);

            XmlResponseMessage getMediaLinksResponseMessage = GetXmlResponseMessageFromUrl(getMediaLinksUrl, _getMediaLinksMethod);

            return(getMediaLinksResponseMessage.ResponseXml);
        }
コード例 #6
0
        public void DeleteMediaTag(MediaItem mediaItem, MediaTag tag)
        {
            string relativePath = GenerateRelativeMediaTagUrl(mediaItem.Url);

            relativePath = relativePath + "/" + tag.TagId.ToString();

            QueryParameterList paramaters = new QueryParameterList();

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

            string deleteMediaTagUrl = OAuth.GenerateURL(ApiUrl, relativePath, _deleteMediaTagMethod, Token, paramaters);

            XmlResponseMessage deleteMediaTagResponseMessage = GetXmlResponseMessageFromUrl(deleteMediaTagUrl, _deleteMediaTagMethod);
        }
コード例 #7
0
        private Privacy GetAlbumsPrivacySettings(string albumPath)
        {
            string relativePath = GenerateRelativeAlbumPrivacyUrl(albumPath);

            QueryParameterList paramaters = new QueryParameterList();

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

            string getAlbumPrivacySettingsUrl = OAuth.GenerateURL(ApiUrl, relativePath, _getAlbumPrivacyMethod, Token, paramaters);

            XmlResponseMessage getAlbumPrivacySettingsResponseMessage = GetXmlResponseMessageFromUrl(getAlbumPrivacySettingsUrl, _getAlbumPrivacyMethod);

            return(GetPrivacyFromResponseMessage(getAlbumPrivacySettingsResponseMessage));
        }
コード例 #8
0
        public MetaData GetMediaMetaData(ref MediaItem mediaItem)
        {
            string relativePath = GenerateRelativeMediaMetaDataUrl(mediaItem.Url);

            QueryParameterList paramaters = new QueryParameterList();

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

            string getMediaMetaDataUrl = OAuth.GenerateURL(ApiUrl, relativePath, _getMediaMetaDataMethod, Token, paramaters);

            XmlResponseMessage getMediaMetaDataResponseMessage = GetXmlResponseMessageFromUrl(getMediaMetaDataUrl, _getMediaMetaDataMethod);

            mediaItem.SetMetaData = MetaData.CreateFromXmlResponseMessage(getMediaMetaDataResponseMessage);
            return(mediaItem.MetaData);
        }
コード例 #9
0
        private Privacy UpdateAlbumPrivacySettings(string albumPath, Privacy privacySetting, string password)
        {
            string relativePath = GenerateRelativeAlbumPrivacyUrl(albumPath);

            QueryParameterList paramaters = new QueryParameterList();

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

            if (privacySetting == Privacy.PUBLIC)
            {
                paramaters.Add(new QueryParameter(_privacy, "public"));
            }
            else
            {
                paramaters.Add(new QueryParameter(_privacy, "private"));
                paramaters.Add(new QueryParameter(_password, password));
            }

            string updateAlbumPrivacySettingsUrl = OAuth.GenerateURL(ApiUrl, relativePath, _updateAlbumPrivacyMethod, Token, paramaters);

            XmlResponseMessage updateAlbumPrivacySettingsResponseMessage = GetXmlResponseMessageFromUrl(updateAlbumPrivacySettingsUrl, _updateAlbumPrivacyMethod);

            return(GetPrivacyFromResponseMessage(updateAlbumPrivacySettingsResponseMessage));
        }
コード例 #10
0
        public UploadOptions GetCurrentUsersUploadOptions()
        {
            string relativePath = GenerateRelativeUsersUploadOptionsUrl();

            QueryParameterList paramaters = new QueryParameterList();

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

            string getCurrentUsersUploadOptionsUrl = OAuth.GenerateURL(ApiUrl, relativePath, _getUsersUploadOptionsMethod, Token, paramaters);

            XmlResponseMessage getCurrentUsersUploadOptionsResponseMessage = GetXmlResponseMessageFromUrl(getCurrentUsersUploadOptionsUrl, _getUsersUploadOptionsMethod);

            CurrentUser.SetUploadOptions = UploadOptions.CreateFromXmlResponseMessage(getCurrentUsersUploadOptionsResponseMessage);
            return(CurrentUser.UploadOptions);
        }
コード例 #11
0
        public UserContactList GetCurrentUsersContacts()
        {
            string relativePath = GenerateRelativeUsersContactsUrl(_currentUser.Username);

            QueryParameterList paramaters = new QueryParameterList();

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

            string getUsersContactsUrl = OAuth.GenerateURL(ApiUrl, relativePath, _getUserContactsMethod, Token, paramaters);

            XmlResponseMessage getUsersContactsResponseMessage = GetXmlResponseMessageFromUrl(getUsersContactsUrl, _getUserContactsMethod);

            _currentUser.SetContact = UserContactList.CreateFromXmlResponseMessage(getUsersContactsResponseMessage);
            return(_currentUser.Contacts);
        }
コード例 #12
0
        public MediaItem GetMediaInformation(ref MediaItem mediaItem)
        {
            string relativePath = GenerateRelativeMediaInformationUrl(mediaItem.Url);

            QueryParameterList paramaters = new QueryParameterList();

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

            string getMediaInformationUrl = OAuth.GenerateURL(ApiUrl, relativePath, _getMediaInformationMethod, Token, paramaters);

            XmlResponseMessage getMediaInformationResponseMessage = GetXmlResponseMessageFromUrl(getMediaInformationUrl, _getMediaInformationMethod);

            mediaItem = MediaItem.CreateFromXmlNode(mediaItem.MediaType, getMediaInformationResponseMessage.ResponseXml.SelectSingleNode("descendant::media"));
            return(mediaItem);
        }
コード例 #13
0
        public MediaTag GetMediaTag(MediaItem mediaItem, int tagId)
        {
            string relativePath = GenerateRelativeMediaTagUrl(mediaItem.Url);

            relativePath = relativePath + "/" + tagId.ToString();

            QueryParameterList paramaters = new QueryParameterList();

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

            string getMediaTagUrl = OAuth.GenerateURL(ApiUrl, relativePath, _getMediaTagMethod, Token, paramaters);

            XmlResponseMessage getMediaTagResponseMessage = GetXmlResponseMessageFromUrl(getMediaTagUrl, _getMediaTagMethod);

            return(MediaTag.CreateFromXmlNode(getMediaTagResponseMessage.ResponseXml.SelectSingleNode("descendant::content")));
        }
コード例 #14
0
        public string GetMediaDescription(ref MediaItem mediaItem)
        {
            string relativePath = GenerateRelativeMediaDescriptionUrl(mediaItem.Url);

            QueryParameterList paramaters = new QueryParameterList();

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

            string getMediaDescriptionUrl = OAuth.GenerateURL(ApiUrl, relativePath, _getMediaDescriptionMethod, Token, paramaters);

            XmlResponseMessage getMediaDescriptionResponseMessage = GetXmlResponseMessageFromUrl(getMediaDescriptionUrl, _getMediaDescriptionMethod);

            XmlNode descriptionNode = getMediaDescriptionResponseMessage.ResponseXml.SelectSingleNode("descendant::description");

            mediaItem.Description = descriptionNode.InnerText;

            return(mediaItem.Description);
        }
コード例 #15
0
        public void UpdateMediaTag(MediaItem mediaItem, MediaTag tag)
        {
            string relativePath = GenerateRelativeMediaTagUrl(mediaItem.Url);

            relativePath = relativePath + "/" + tag.TagId.ToString();

            QueryParameterList paramaters = new QueryParameterList();

            paramaters.Add(new QueryParameter(_format, "xml"));
            if (tag.TopLeftX == -1)
            {
                paramaters.Add(new QueryParameter("topleftx", tag.TopLeftX.ToString()));
            }
            if (tag.TopLeftY == -1)
            {
                paramaters.Add(new QueryParameter("toplefty", tag.TopLeftY.ToString()));
            }
            if (tag.BottomRightX == -1)
            {
                paramaters.Add(new QueryParameter("bottomrightx", tag.BottomRightX.ToString()));
            }
            if (tag.BottomRightY == -1)
            {
                paramaters.Add(new QueryParameter("bottomrighty", tag.BottomRightY.ToString()));
            }
            if (string.IsNullOrEmpty(tag.Name) == false)
            {
                paramaters.Add(new QueryParameter("tag", tag.Name));
            }
            if (string.IsNullOrEmpty(tag.Contact) == false)
            {
                paramaters.Add(new QueryParameter("contact", tag.Contact));
            }
            if (string.IsNullOrEmpty(tag.Url) == false)
            {
                paramaters.Add(new QueryParameter("tagurl", tag.Url));
            }

            string updateMediaTagUrl = OAuth.GenerateURL(ApiUrl, relativePath, _updateMediaTagMethod, Token, paramaters);

            XmlResponseMessage updateMediaTagResponseMessage = GetXmlResponseMessageFromUrl(updateMediaTagUrl, _updateMediaTagMethod);
        }
コード例 #16
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));
        }
コード例 #17
0
        private Album GetAlbum(string albumPath, bool recurse, string view, string media, bool paginated, int page, int perpage)
        {
            string relativePath = GenerateRelativeAlbumUrl(albumPath);

            QueryParameterList paramaters = new QueryParameterList( );

            paramaters.Add(new QueryParameter(_format, "xml"));
            paramaters.Add(new QueryParameter(_recurse, recurse ? "1" : "0"));
            paramaters.Add(new QueryParameter(_view, view));
            paramaters.Add(new QueryParameter(_media, media));
            paramaters.Add(new QueryParameter(_paginated, paginated ? "1" : "0"));
            paramaters.Add(new QueryParameter(_page, page.ToString()));
            paramaters.Add(new QueryParameter(_perpage, perpage.ToString()));

            string getUsersAlbumUrl = OAuth.GenerateURL(ApiUrl, relativePath, _getAlbumMethod, Token, paramaters);

            XmlResponseMessage getUsersAlbumResponseMessage = GetXmlResponseMessageFromUrl(getUsersAlbumUrl, _getAlbumMethod);

            return(new Album(getUsersAlbumResponseMessage.ResponseXml.SelectSingleNode("descendant::album")));
        }
コード例 #18
0
        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;
            }
        }