假设我有这段代码,它将所有消息历史记录放在数组中的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)
[有一些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)