PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, November 18, 2022

[FIXED] How to pass start and end date in Twilio call logs using PHP Curl

 November 18, 2022     curl, php, twilio, twilio-api, twilio-php     No comments   

Issue

I need to get the call logs from my twilio account.

I used following links

https://api.twilio.com/2010-04-01/Accounts/AC199564de248bcb4df3968fab5481bf8a/Calls.csv?PageSize=1000

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)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

1,209,795

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © 2025 PHPFixing