Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@po5i
Forked from caseysoftware/delete-recordings.php
Last active April 9, 2018 22:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save po5i/a05b1b074d97f5ad4d17181f1bb7804e to your computer and use it in GitHub Desktop.
Save po5i/a05b1b074d97f5ad4d17181f1bb7804e to your computer and use it in GitHub Desktop.
This is a simple script using the Twilio PHP Helper library to retrieve Recordings within a certain date range and then delete them.
<?php
// Get the PHP helper library from https://twilio.com/docs/libraries/php
require_once '/path/to/vendor/autoload.php';
use Twilio\Rest\Client;
// Your Account Sid and Auth Token from twilio.com/console
$sid = "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
$token = "your_auth_token";
$twilio = new Client($sid, $token);
$recordings = $twilio->recordings
->read(array(
'callSid' => "CAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
'dateCreatedBefore' => '2011-08-01'
'dateCreatedAfter' => '2011-07-05 08:00:00'
), 50);
foreach ($recordings as $record) {
echo "Deleting: " . $recording->sid . " -- " . $recording->date_created . "\n";
$client->recordings($recording->sid)->delete();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment