Issue
I need to get the call logs from my twilio account.
I used following links
Here I need to pass start and end date.
Solution
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.
OR you can use this code
<?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;
}
Answered By - Balvant parmar Answer Checked By - Cary Denson (PHPFixing Admin)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.