使用 Python Rest API 从 Twilio 检索通话记录

Retrieving call log from Twilio using the Python Rest API

我正在尝试检索从 2017 年 1 月 1 日到现在完成的通话列表。根据我试过的文档:

calls=client.calls.list(started_after=date(2017,1,1))
for call in calls:
    print("Call to: {} call from {} duration {}".format(call.to,call.from_, call.duration))

我正在检索通话记录,但我得到的只是当天的通话。

这里是 Twilio 开发人员布道师。

我相信排序顺序为list of calls is in reverse chronological order, so you are getting the most recent calls first. All list resources from Twilio are paginated以便检索更多。默认页面大小为 50。

您最多可以将 pageSize 调至 1000 条,以便在一次 API 调用中获得更多记录。

calls=client.calls.list(started_after=date(2017,1,1), page_size=1000)

或者,您可以使用 Python helper library's iter method, to iterate over the list of calls,进行所有需要的 API 调用以获取所有数据。

calls=client.calls.iter(started_after=date(2017,1,1))

如果有帮助请告诉我。