Twilio仅通过Python从收件人检索邮件历史记录

问题描述 投票:0回答:1

假设我有这段代码,它将所有消息历史记录放在数组中的twilio编号及其收件人之间。是否有一种方法只能从所有收件人而不是发件人中检索消息历史记录(我是谁)

from twilio.rest import Client

account_sid = 'xxxx'
auth_token = 'xxxx'
client = Client(account_sid, auth_token)


text=[]
messages = client.messages.list()
for record in messages:
    print(record.body)
    text.append(record.body)

print(text)
python python-3.x twilio twilio-php twilio-programmable-chat
1个回答
0
投票

[有一些filter criteria with the above command的示例,您可以过滤到:到您的特定Twilio号,以仅看到对话的那一边(通过主体键)。

# Download the helper library from https://www.twilio.com/docs/python/install
from datetime import datetime
from twilio.rest import Client


# Your Account Sid and Auth Token from twilio.com/console
# DANGER! This is insecure. See http://twil.io/secure
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
client = Client(account_sid, auth_token)

messages = client.messages.list(
                               to='+15558675310',
                               limit=20
                           )

for record in messages:
    print(record.sid)
© www.soinside.com 2019 - 2024. All rights reserved.