public void AddMediaTag(MediaItem mediaItem, MediaTag tag) { string relativePath = GenerateRelativeMediaTagUrl(mediaItem.Url); QueryParameterList paramaters = new QueryParameterList(); paramaters.Add(new QueryParameter(_format, "xml")); paramaters.Add(new QueryParameter("topleftx", tag.TopLeftX.ToString())); paramaters.Add(new QueryParameter("toplefty", tag.TopLeftY.ToString())); paramaters.Add(new QueryParameter("bottomrightx", tag.BottomRightX.ToString())); paramaters.Add(new QueryParameter("bottomrighty", tag.BottomRightY.ToString())); 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 addMediaTagUrl = OAuth.GenerateURL(ApiUrl, relativePath, _addMediaTagMethod, Token, paramaters); XmlResponseMessage addMediaTagResponseMessage = GetXmlResponseMessageFromUrl(addMediaTagUrl, _addMediaTagMethod); }
/// <summary> /// Requests the Auth token and secret for the API /// And stores into _consumerToken /// </summary> private void RequestLoginToken() { string loginTokenUrl = OAuth.GenerateURL(ApiUrl, _loginTokenUrl, _loginTokenMethod, new PhotobucketToken()); ResponseMessage loginTokenResponseMessage = GetResponseMessageFromUrl(loginTokenUrl, _loginTokenMethod); _consumerToken = OAuth.GetConsumerTokenFromResponse(loginTokenResponseMessage.ResponseString); _appAuthorized = true; }
private void DeleteAlbum(string albumPath) { string relativePath = GenerateRelativeAlbumUrl(albumPath); QueryParameterList paramaters = new QueryParameterList(); paramaters.Add(new QueryParameter(_format, "xml")); string deleteAlbumUrl = OAuth.GenerateURL(ApiUrl, relativePath, _deleteAlbumMethod, Token, paramaters); XmlResponseMessage deleteAlbumResponseMessage = GetXmlResponseMessageFromUrl(deleteAlbumUrl, _deleteAlbumMethod); }
public void RotateImage(MediaItem mediaItem, int degrees) { string relativePath = GenerateRelativeRotateImageUrl(mediaItem.Url); QueryParameterList paramaters = new QueryParameterList(); paramaters.Add(new QueryParameter(_format, "xml")); string rotateImageUrl = OAuth.GenerateURL(ApiUrl, relativePath, _rotateImageMethod, Token, paramaters); XmlResponseMessage rotateImageResponseMessage = GetXmlResponseMessageFromUrl(rotateImageUrl, _rotateImageMethod); }
private void RenameAlbum(string origAlbumPath, string newAlbumName) { string relativePath = GenerateRelativeAlbumUrl(origAlbumPath); QueryParameterList paramaters = new QueryParameterList(); paramaters.Add(new QueryParameter(_name, newAlbumName)); paramaters.Add(new QueryParameter(_format, "xml")); string renameAlbumUrl = OAuth.GenerateURL(ApiUrl, relativePath, _renameAlbumMethod, Token, paramaters); XmlResponseMessage renameAlbumResponseMessage = GetXmlResponseMessageFromUrl(renameAlbumUrl, _renameAlbumMethod); }
/// <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)); }
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)); }
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; }
public void ShareMediaViaEmail(MediaItem mediaItem, string email, string body) { string relativePath = GenerateRelativeShareUrl(mediaItem.Url); QueryParameterList paramaters = new QueryParameterList(); paramaters.Add(new QueryParameter(_format, "xml")); paramaters.Add(new QueryParameter("body", body)); paramaters.Add(new QueryParameter("email", email)); string shareMediaViaEmailUrl = OAuth.GenerateURL(ApiUrl, relativePath, _shareMediaViaEmailMethod, Token, paramaters); XmlResponseMessage shareMediaViaEmailResponseMessage = GetXmlResponseMessageFromUrl(shareMediaViaEmailUrl, _shareMediaViaEmailMethod); }
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); }
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)); }
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 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); }
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); }
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); }
public void SetMediaTitle(ref MediaItem mediaItem, string title) { string relativePath = GenerateRelativeMediaTitleUrl(mediaItem.Url); QueryParameterList paramaters = new QueryParameterList(); paramaters.Add(new QueryParameter(_format, "xml")); paramaters.Add(new QueryParameter(_title, title)); string setMediaTitleUrl = OAuth.GenerateURL(ApiUrl, relativePath, _setMediaTitleMethod, Token, paramaters); XmlResponseMessage setMediaTitleResponseMessage = GetXmlResponseMessageFromUrl(setMediaTitleUrl, _setMediaTitleMethod); mediaItem.Title = title; }
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); }
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); }
private Album CreateNewAlbum(string albumName, string albumPath) { string relativePath = GenerateRelativeAlbumUrl(albumPath); QueryParameterList paramaters = new QueryParameterList( ); paramaters.Add(new QueryParameter(_name, albumName)); paramaters.Add(new QueryParameter(_format, "xml")); string createNewAlbumUrl = OAuth.GenerateURL(ApiUrl, relativePath, _createAlbumMethod, Token, paramaters); XmlResponseMessage createNewAlbumResponseMessage = GetXmlResponseMessageFromUrl(createNewAlbumUrl, _createAlbumMethod); return(new Album(albumName, albumPath)); }
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"))); }
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)); }
public AlbumList GetAllUsersAlbums(string username) { string relativePath = GenerateRelativeAlbumUrl(username); QueryParameterList paramaters = new QueryParameterList(); paramaters.Add(new QueryParameter(_format, "xml")); paramaters.Add(new QueryParameter(_recurse, "1")); paramaters.Add(new QueryParameter(_view, "flat")); paramaters.Add(new QueryParameter(_media, "none")); string getAllUsersAlbumsUrl = OAuth.GenerateURL(ApiUrl, relativePath, _getAlbumMethod, Token, paramaters); XmlResponseMessage getAllUsersAlbumsResponseMessage = GetXmlResponseMessageFromUrl(getAllUsersAlbumsUrl, _getAlbumMethod); return(AlbumList.CreateFromXmlResponseMessage(getAllUsersAlbumsResponseMessage)); }
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); }
/// <summary> /// Requests the token and secret for the user that logged in /// </summary> public UserToken RequestUserToken() { if (!AppAuthorized) { throw (new PhotobucketApiException("App Not Authorized")); } string userTokenUrl = OAuth.GenerateURL(_apiUrl, _userTokenUrl, _userTokenMethod, _consumerToken); ResponseMessage userTokenResponseMessage = GetResponseMessageFromUrl(userTokenUrl, _userTokenMethod); _userToken = OAuth.GetUserTokenFromResponse(userTokenResponseMessage.ResponseString); _userLoggedOn = true; _appAuthorized = false; _consumerToken = null; _currentUser = new User(_userToken.Username); return(_userToken); }
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"))); }
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"))); }
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)); }
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 UploadOptions UpdateCurrentUsersUploadOptions(ImageSize imageSize, bool autoTagging) { string relativePath = GenerateRelativeUsersUploadOptionsUrl(); QueryParameterList paramaters = new QueryParameterList(); paramaters.Add(new QueryParameter(_format, "xml")); paramaters.Add(new QueryParameter(_defaultimagesize, Convert.ToString(imageSize))); paramaters.Add(new QueryParameter(_autotagging, autoTagging ? "1" : "0")); string updateCurrentUsersUploadOptionsUrl = OAuth.GenerateURL(ApiUrl, relativePath, _updateUsersUploadOptionsMethod, Token, paramaters); XmlResponseMessage updateCurrentUsersUploadOptionsResponseMessage = GetXmlResponseMessageFromUrl(updateCurrentUsersUploadOptionsUrl, _updateUsersUploadOptionsMethod); UploadOptions userUploadOptions = new UploadOptions(); userUploadOptions.SetDefaultImageSize = imageSize; userUploadOptions.SetAutoTagging = autoTagging; CurrentUser.SetUploadOptions = userUploadOptions; return(_currentUser.UploadOptions); }
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; } }