2017-10-12 43 views
0

我試圖做一個簡單的,刪除所有記錄,我不斷收到此錯誤拋出:致命錯誤:未捕獲的異常「Twilio 例外 EnvironmentException」與消息「無法解析主機: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); 
    } 
    ?> 
+0

根據代碼,它看起來像'getPage()'正在尋找'$ targetUrl'。 – aynber

回答

1

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(); 
} 
+0

好的,去那裏!它正在嘗試!現在得到: 致命錯誤:調用未定義的方法Twilio \ Rest \ Api \ V2010 \ Account \ RecordingList :: delete()在C:\ xampp \ htdocs \ deleteallrecordings.php on line 14 –

+0

啊,道歉,沒有注意到那一點是錯誤的。我已經更新了我的答案,但是您需要'$ client-> recordings($ recording-> sid) - > delete();'。 – philnash

+0

你太棒了!非常感謝!! –

0

最終結果,很棒!再次感謝您的支持phildash

<?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(); 
} 
?> 
相關問題