Skip to content

Instantly share code, notes, and snippets.

@caseysoftware
Created February 21, 2012 06:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save caseysoftware/1874567 to your computer and use it in GitHub Desktop.
Save caseysoftware/1874567 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
// This assumes you have the Twilio PHP Helper library
require 'Services/Twilio.php';
// This is a file with my Account Sid and AuthToken
include 'credentials.php';
$client = new Services_Twilio($accountsid, $authtoken);
/*
* For the getIterator array, these are valid options:
* "DateCreated>" or "DateCreated<"
*/
foreach ($client->account->recordings->getIterator(0, 50, array('DateCreated>' => '2011-07-05 08:00:00', 'DateCreated<' => '2011-08-01')) as $recording) {
echo $recording->sid." -- ". $recording->date_created . "\n";
$client->account->recordings->delete($recording->sid);
}
@moizchhatriwala
Copy link

What I need to do if I want to delete all the records which are older then 1 day dynamically, currently hardcoded date is passed, I need the php code for doing same, please help me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment