我需要从我的twilio帐户获取通话记录。
我使用了以下链接
在这里,我需要传递开始和结束日期。
答案 0 :(得分:1)
You can like this
$StartTime = '2018-11-13';
$username = $value['accountSid'];
$password = $value['authToken'];
$url = 'https://api.twilio.com/2010-04-01/Accounts/'.$value['accountSid'].'/Calls.json?StartTime='.$StartTime.'T00%3A00%3A00Z';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_USERPWD, $username . ":" . $password);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$server_output = curl_exec ($ch);
$decode = json_decode($server_output,TRUE);
It's working form me get all call logs from twilio.
或者您可以使用此代码
<?php
// Get the PHP helper library from twilio.com/docs/php/install
require_once '/path/to/vendor/autoload.php'; // Loads the library
use Twilio\Rest\Client;
// Your Account Sid and Auth Token from twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";
$client = new Client($sid, $token);
$records = $client->usage->records->read(
array(
"category" => "calls-inbound",
"startDate" => "2012-09-01",
"endDate" => "2012-09-30"
)
);
// Loop over the list of records and echo a property for each one
foreach ($records as $record) {
echo $record->price;
}