Fatal error: Uncaught exception 'Twilio\Exceptions\EnvironmentException' with message 'Could not resolve host: 0

Fatal error: Uncaught exception 'Twilio\Exceptions\EnvironmentException' with message 'Could not resolve host: 0

我正在尝试做一个简单的操作,即删除所有录音,但我不断收到此错误:

Fatal error: Uncaught exception 'Twilio\Exceptions\EnvironmentException' with message 'Could not resolve host: 0' in C:\xampp\htdocs\twilio-php-master\Twilio\Http\CurlClient.php:41 Stack trace: #0

使用代码如下,请帮忙!

<?php
    require_once 'twilio-php-master/Twilio/autoload.php';
    use Twilio\Rest\Client;
    // Set our AccountSid and AuthToken
    $sid = 'MYSID';
    $token = 'MYTOKEN';

    // Your Account Sid and Auth Token from twilio.com/user/account
    $client = new Client($sid, $token);

    foreach ($client->account->recordings->getPage(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);
    }
    ?>

此处为 Twilio 开发人员布道师。

The getPage method only takes a single argument, $targetUrl.

您可能想改用 read,这会将所有录音加载到一个列表中,然后您可以遍历并删除该列表。

foreach ($client->account->recordings->read(array('DateCreated>' => '2011-07-05 08:00:00', 'DateCreated<' => '2011-08-01')) as $recording) {
    echo $recording->sid." -- ". $recording->date_created . "\n";
    $client->recordings($recording->sid)->delete();
}

最终结果,效果很好!!再次感谢 philnash

<?php
require_once('PHPMailer-master/PHPMailerAutoload.php');
require_once 'twilio-php-master/Twilio/autoload.php';
use Twilio\Rest\Client;
// Set our AccountSid and AuthToken
$sid = 'SID';
$token = 'TOKEN';

// Your Account Sid and Auth Token from twilio.com/user/account
$client = new Client($sid, $token);

foreach ($client->account->recordings->read(array('DateCreated>' => '2017-09-01 08:00:00', 'DateCreated<' => '2017-10-13')) as $recording) {
    echo $recording->sid." -- ". $recording->dateCreated->format('y/m/d') . "\n";
    $client->recordings($recording->sid)->delete();
}
?>