Beispiel #1
0
        private async Task <string> GetPhotoUrl()
        {
            var backupUrl = @"https://cdn.pixabay.com/photo/2016/04/01/09/26/emote-1299362_1280.png";

            // GET DROPBOX FOLDERS
            var photoUrl = string.Empty;

            try
            {
                // CREATE DROPBOX HELPER
                var helper = new DropboxHelper();

                // GET ALL PHOTO PATHS
                var filePaths = await helper.GetFilePaths();

                // SELECT RANDOM FILE
                var index = new Random().Next(filePaths.Count);

                // GET PUBLICLY ACCESSIBLE URI
                photoUrl = await helper.GetFileUri(filePaths[index]);
            }
            catch
            {
                // If anything fails, send a sad face
                photoUrl = backupUrl;
            }

            return(photoUrl);
        }