简体   繁体   中英

How to get call logs for last 10 days using Twilio API?

I am working on a Twilio project in which I need to fetch call logs for last 10 days in a single call, but I see no favourable parameters in twilio api docs ( https://www.twilio.com/docs/api/voice/call#list-get ) that can help me. I tried DateCreated , StartTime parameters but they work differently. Could anyone help me out here please?

Thanks in advance.

I think you are in the wrong area of the api, i think the area you are looking at is for calls currently in progress.

Try usage-records

Sometimes when I'm stuck, I run a curl example in Twilio's API explorer ; This shows me 2 things:

  1. Options used in call
  2. What to expect as results

Good luck

Try the startTimeAfter and startTimeBefore parameters.


// Download the Node helper library from twilio.com/docs/node/install
// These identifiers are your accountSid and authToken from
// https://www.twilio.com/console
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const client = require('twilio')(accountSid, authToken);

const filterOpts = {
  status: 'completed',
  startTimeAfter: '2016-07-04',
  startTimeBefore: '2016-07-06',
};

client.calls.each(filterOpts, call => console.log(call.direction));

Twilio Docs:
https://www.twilio.com/docs/api/voice/call?code-sample=code-retrieve-completed-calls-from-a-period-of-time&code-language=js&code-sdk-version=3.x

curl 'https://api.twilio.com/2010-04-01/Accounts/[ACCOUNT SID]/Calls.json?StartTime%3E=2020-06-01T0&EndTime%3C=2020-07-01' -u [ACCOUT SID]:[AuthToken]

This curl script will give you a list of calls from 2020-06-01 to 2020-07-01. Don't forget to substitute your ACCOUNT_SID and AuthToken (without the brackets)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM