Example #1
0
        public List<AlbumDetails> GetAlbums(string username)
        {
            List<AlbumDetails> albumDetails = new List<AlbumDetails>();
            dynamic albums = Get("/" + username + "/albums");
            foreach (dynamic albumInfo in albums.data)
            {
                AlbumDetails album = new AlbumDetails();
                if(albumInfo.name != null)
                    album.AlbumName = albumInfo.name;
                if(albumInfo.description != null)
                    album.AlbumDescription = albumInfo.description;
                if(albumInfo.id != null)
                    album.Id = albumInfo.id;
                if(albumInfo.count != null)
                    album.PhotoCount = albumInfo.count;
                if(albumInfo.can_upload != null)
                    album.CanUpload = albumInfo.can_upload;

                albumDetails.Add(album);
            }
            return albumDetails;
        }
Example #2
0
        public bool CreateAlbum(AlbumDetails album)
        {
            var albumParameters = new Dictionary<string, object>
                                      {
                                          {"message", album.AlbumDescription},
                                          {"name", album.AlbumName}
                                      };
            var result = Post("/me/albums", albumParameters) as JsonObject;

            return true;
        }
Example #3
0
        private static bool PostFacebookAlbum(string[] parameters, string username)
        {
            try
            {
                var album = new AlbumDetails();
                Dictionary<string, string> options = GetParameters(parameters, 3);
                foreach (var option in options)
                {
                    switch (option.Key)
                    {
                        case "-an":
                            album.AlbumName = option.Value;
                            break;
                        case "-ad":
                            album.AlbumDescription = option.Value;
                            break;
                        default:
                            throw new InvalidCommand("Unknown parameter: " + option.Key);
                    }
                }
                if (album.AlbumName == null)
                    throw new InvalidCommand("Album name missing. Use the -an parameter to specify it");

                return _apiManager.FacebookClient.CreateAlbum(album);
            }
            catch (Exception exception)
            {
                if (exception is InvalidCommand)
                    Console.WriteLine(exception.Message);
                return false;
            }
        }