public static async Task ManagingNodes(SmugMugAPI api) { //Get access to the logged in user User user = await api.GetAuthenticatedUser(); Console.WriteLine("{0} is currently authenticated", user.Name); //Get the root node ID string defaultNodeID = api.GetDefaultNodeID(user); //Create a new folder node at the root Node folderNode = await api.CreateNode(NodeType.Folder, "TestFolderNode", defaultNodeID); Console.WriteLine("Created folder node {0}", folderNode.Name); //Create a new album node in that folder Dictionary <string, string> arguments = new Dictionary <string, string>() { { "Description", "test description" } }; Node albumNode = await api.CreateNode(NodeType.Album, "TestAlbumNode", folderNode.NodeID, arguments); Console.WriteLine("Created album node {0} {1}", albumNode.Name, albumNode.Description); Dictionary <string, string> albumUpdates = new Dictionary <string, string>() { { "Name", "Updated Album Name" }, { "Description", "Updated description" }, { "SortDirection", "Ascending" } }; Node updatedAlbumNode = await api.UpdateNode(albumNode, albumUpdates); Console.WriteLine("Updated album node {0}: {1}", updatedAlbumNode.Name, updatedAlbumNode.Description); //Delete the newly created nodes await api.DeleteNode(folderNode); }
public static async Task ManagingFoldersAndAlbums(SmugMugAPI api) { //Get access to the logged in user User user = await api.GetAuthenticatedUser(); Console.WriteLine("{0} is currently authenticated", user.Name); //Create a new folder at the root Folder folder = await api.CreateFolder("TestFolder", user, ""); Console.WriteLine("Created folder {0}", folder.Name); //Create a new album in that folder Dictionary <string, string> arguments = new Dictionary <string, string>() { { "Description", "test description" } }; Album album = await api.CreateAlbum("TestAlbum", folder, arguments); Console.WriteLine("Created album {0}: {1}", album.Name, album.Description); Dictionary <string, string> albumUpdates = new Dictionary <string, string>() { { "Name", "Updated Album Name" }, { "Description", "Updated description" }, { "SortDirection", "Ascending" } }; Album updatedAlbum = await api.UpdateAlbum(album, albumUpdates); Console.WriteLine("Updated album {0}: {1}", updatedAlbum.Name, updatedAlbum.Description); //Delete the newly created album and folder await api.DeleteAlbum(album); await api.DeleteFolder(folder); }
public static async Task WorkingWithFoldersAndAlbums(SmugMugAPI api) { //Get access to the user you want to enumerate albums for User user = await api.GetUser("cmac"); Console.WriteLine(user.Name); //Get a specific folder, "SmugMug" Folder folder = await api.GetFolder(user, "SmugMug"); Console.WriteLine(folder); //Get a specific subfolder, "Heroes" under folder "SmugMug" Folder subFolder = await api.GetFolder("cmac", "SmugMug/Heroes"); Console.WriteLine(subFolder); //Get the first 100 albums for the user List <Album> albums = await api.GetAlbums(user, 100); Console.WriteLine("The first album is '{0}' with {1} images", albums[0].Name, albums[0].ImageCount); //Get the featured albums for the user List <Album> featuredAlbums = await api.GetFeaturedAlbums(user); Console.WriteLine("{0} has {1} featured albums", user.Name, featuredAlbums.Count); //Get a specific album, "SJT3DX" Album album = await api.GetAlbum("SJT3DX"); Console.WriteLine("Album '{0}' has {1} images", album.Name, album.ImageCount); }
public static async Task WorkingWithUsers(SmugMugAPI api) { //Get a given user User user = await api.GetUser("justmarks"); Console.WriteLine(user.Name); //Get the user's profile UserProfile userProfile = await api.GetUserProfile(user); Console.WriteLine("{0} - Twitter:", userProfile.DisplayName, userProfile.Twitter); }
public static async Task WorkingWithAlbumImages(SmugMugAPI api) { //Get a specific album node, "TrBCmb" Album album = await api.GetAlbum("TrBCmb"); Console.WriteLine("Album '{0}' has {1} images", album.Name, album.ImageCount); //Get all the images in the given album var albumImages = await api.GetAlbumImages(album); //Get a specific image in the given album var albumImage = await api.GetAlbumImage(album, "ktwWSFX-0"); Console.WriteLine("'{0}' ({1}) with keywords \"{2}\"", albumImage.Title, albumImage.FileName, albumImage.Keywords); }
public void Test() { string apikey = SmugItConfigurationManager.Instance.Configuration.Credential.ApiKey; OAuthCredentials oAuthCredentials = new OAuthCredentials(apikey); // CONSUMER_KEY is the API Key received from SmugMug` SmugMugAPI api = new SmugMugAPI(LoginType.Anonymous, oAuthCredentials); //var test = api.GetUser("corleone00"); //var album = api.GetAlbum("Etna2011").GetAwaiter().GetResult(); //Get access to the user you want to enumerate albums for User user = api.GetUser("alberic").GetAwaiter().GetResult(); Console.WriteLine(user.Name); var rootNode = api.GetRootNode(user).GetAwaiter().GetResult();// .GetFolder(user, "").GetAwaiter().GetResult(); var nodes = api.GetChildNodes(rootNode).GetAwaiter().GetResult(); }
public static SmugMugAPI AuthenticateUsingAnonymous() { //Access OAuth keys from App.config string consumerKey = null; Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); var keySetting = config.AppSettings.Settings[CONSUMERTOKEN]; if (keySetting != null) { consumerKey = keySetting.Value; } if (String.IsNullOrEmpty(consumerKey)) { throw new ConfigurationErrorsException("The OAuth consumer token must be specified in App.config"); } //Connect to SmugMug using Anonymous access SmugMugAPI apiAnonymous = new SmugMugAPI(LoginType.Anonymous, new OAuthCredentials(consumerKey)); return(apiAnonymous); }
public static async Task WorkingWithNodes(SmugMugAPI api) { //Get access to the user you want to enumerate albums for User user = await api.GetUser("cmac"); Console.WriteLine(user.Name); //Get the root node for the given user Node rootNode = await api.GetRootNode(user); Console.WriteLine(rootNode); //Get the children of the root node List <Node> childNodes = await api.GetChildNodes(rootNode); Console.WriteLine("The first node '{0}' is a {1}", childNodes[0].Name, childNodes[0].Type); //Get a specific node, "XWx8t" Node node = await api.GetNode("XWx8t"); Console.WriteLine("Node '{0}' is a {1}", node.Name, node.Type); }
public static SmugMugAPI AuthenticateUsingOAuth() { //Access OAuth keys from App.config string consumerKey = null; Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); var keySetting = config.AppSettings.Settings[CONSUMERTOKEN]; if (keySetting != null) { consumerKey = keySetting.Value; } if (String.IsNullOrEmpty(consumerKey)) { throw new ConfigurationErrorsException("The OAuth consumer token must be specified in App.config"); } string secret = null; keySetting = config.AppSettings.Settings[CONSUMERSECRET]; if (keySetting != null) { secret = keySetting.Value; } if (String.IsNullOrEmpty(secret)) { throw new ConfigurationErrorsException("The OAuth consumer token secret must be specified in App.config"); } //Generate oAuthCredentials using OAuth library OAuthCredentials oAuthCredentials = GenerateOAuthAccessToken(consumerKey, secret); //Connect to SmugMug using oAuth SmugMugAPI apiOAuth = new SmugMugAPI(LoginType.OAuth, oAuthCredentials); return(apiOAuth); }