Skip to content

Instantly share code, notes, and snippets.

@dprothero
Created October 29, 2018 22:13
Show Gist options
  • Save dprothero/20600365507f146b7b845e0e285efd5b to your computer and use it in GitHub Desktop.
Save dprothero/20600365507f146b7b845e0e285efd5b to your computer and use it in GitHub Desktop.
Using a unique TwilioRestClient for requests
string accountSid = string.Empty;
string authToken = string.Empty;
if (!string.IsNullOrEmpty(ConfigurationManager.AppSettings["TwilioAccountSID"]) && !string.IsNullOrEmpty(ConfigurationManager.AppSettings["TwilioAuthToken"]))
{
accountSid = ConfigurationManager.AppSettings["TwilioAccountSID"];
authToken = ConfigurationManager.AppSettings["TwilioAuthToken"];
var readClient = new TwilioRestClient(accountSid, authToken);
var writeClient = new TwilioRestClient(accountSid, authToken);
var deleteDateRange = DateTime.UtcNow.AddDays(-1);
var recordings = RecordingResource.Read(dateCreatedBefore: deleteDateRange, client: readClient);
foreach (var recording in recordings)
{
RecordingResource.Delete(recording.Sid, client: writeClient);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment