コード例 #1
0
        private static string GetRecording(string recordingUrl, int dealerId)
        {
            try
            {
                //var recordingUrl = "https://media.devtest.ringcentral.com/restapi/v1.0/account/246021004/recording/4703046004/content";
                //var fileUniqueName = Guid.NewGuid();
                var dbset = new DbUtilities();
                var path  = dbset.GetAudioPath();

                var audioFileName = "RingCentral_" + recordingUrl.Split('/')[8] + ".mp3";
                var audioPath     = $"{dealerId}\\";
                var webPath       = $"{dealerId}/";

                Directory.CreateDirectory(Path.Combine(path.PhysicalFolder, audioPath));
                var wc = new WebClient
                {
                    UseDefaultCredentials = true,
                    Credentials           = new NetworkCredential("administrator", "aalwayss!") // Check with Tim where to get this, else when it got change we have to change here
                };
                wc.Headers.Add("Authorization", $"Bearer " + accessToken);
                wc.DownloadFile(recordingUrl, Path.Combine(path.PhysicalFolder, audioPath) + audioFileName);
                return(Path.Combine(path.WebUrl, webPath) + audioFileName);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }