Skip to content

Instantly share code, notes, and snippets.

@caseysoftware
Created February 22, 2012 06:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save caseysoftware/1881959 to your computer and use it in GitHub Desktop.
Save caseysoftware/1881959 to your computer and use it in GitHub Desktop.
This is a simple script using the Twilio PHP Helper library to retrieve Calls within a certain date range and the delete their associated recordings if they're particularly short.
<?php
require 'Services/Twilio.php';
include 'credentials.php';
$toNumber = "{fill this in with your number}";
$client = new Services_Twilio($accountsid, $authtoken);
$calls = $client->account->calls->getIterator(0, 50, array("To" => $toNumber, "StartTime<" => "2011-11-10"));
foreach ($calls as $call) {
if ($call->duration < 20) {
echo $call->sid . " -- " . $call->start_time . "\n";
$recordings = $call->recordings;
foreach($recordings as $recording) {
echo $recording->sid."\n";
$client->account->recordings->delete($recording->sid);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment