-
-
Save po5i/2da778a0e32134fd110f88486471ec0e 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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"; | |
$toNumber = "{fill this in with your number}"; | |
$twilio = new Client($sid, $token); | |
$calls = $client->calls->read( | |
array("to" => $toNumber, "startTimeBefore" => "2011-11-10") | |
); | |
foreach ($calls as $call) { | |
if ($call->duration < 20) { | |
echo "Call: " . $call->sid . " -- " . $call->start_time . "\n"; | |
$recordings = $call->recordings; | |
foreach($recordings as $recording) { | |
echo "Deleting: " . $recording->sid . "\n"; | |
$client->recordings($recording->sid)->delete(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment