【问题标题】:Get a list of calls from startDate to endDate with Twilio API in Node.js使用 Node.js 中的 Twilio API 获取从 startDate 到 endDate 的调用列表
【发布时间】:2021-04-29 19:45:29
【问题描述】:

我正在使用 Twilio API 来收集一些关于我们的通话使用情况的数据。当我像这样调用监视器警报的列表函数时:

  const endDate = "2021-04-29";
  const startDate = "2021-04-23";
  const alerts = await client.monitor.alerts.list({
    endDate,
    logLevel: "error",
    startDate,
  });

它列出了我从开始日期到结束日期的所有呼叫,但是当我使用时

  const calls = await client.calls.list({
    endDate: endDate,
    startDate: startDate,
    limit: 100000,
  });

它超时并且永远不会返回任何东西。

【问题讨论】:

    标签: javascript node.js twilio twilio-php


    【解决方案1】:

    这里是 Twilio 开发者宣传员。

    Alerts API 确实通过startDateendDate 参数过滤了它的响应。但是,Calls Resource 通过startTimeendTime 参数过滤调用。我认为您的脚本超时,因为它试图一次加载 50 页中的 100,000 个调用。

    在两个日期之间进行搜索时,可以使用startTimeAfterendTimeBefore 参数。所以我会像这样更新你的脚本:

      const endDate = "2021-04-29";
      const startDate = "2021-04-23";
    
      const calls = await client.calls.list({
        endTimeBefore: endDate,
        startTimeAfter: startDate,
        limit: 100000,
      });
    

    让我知道你是怎么做的。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-03-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-03-08
      相关资源
      最近更新 更多