我正在尝试保存在数据库中发送和接收的消息,包括消息sid,消息正文,以便我可以使用某些逻辑处理它们。
class OutgoingMessage(models.Model):
''' Table of SMS messages that are sent out to users by Twilio '''
outgoing_sid = models.CharField(max_length=40)
sent_date = models.DateTimeField()
sender = models.ForeignKey(TwilioNumber, related_name='outgoing_messages')
recipient = models.ForeignKey(Caller, related_name='outgoing_messages')
message_body = models.TextField(max_length=1600)
class IncomingMessage(models.Model):
''' Table of SMS messages received by Twilio from users '''
incoming_sid = models.CharField(max_length=40)
sent_date = models.DateTimeField()
sender = models.ForeignKey(Caller, related_name='incoming_messages')
recipient = models.ForeignKey(TwilioNumber, related_name='incoming_messages')
message_body = models.TextField(max_length=1600)
是否有一种直接的方式从Twilio发送的消息中获取消息sid后立即发送?从传入的消息中获取sid非常简单,但反过来并不是很清楚。
我正在尝试寻找使用Cookie的替代方法,如建议in this post
答案 0 :(得分:1)
我找到了答案here
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import TwilioRestClient
# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = "AC1ab0bb368322688c3d6cbb1355aeef9b"
auth_token = "{{ auth_token }}"
client = TwilioRestClient(account_sid, auth_token)
message = client.messages.create(body="Jenny please?! I love you <3",
to="+15558675309",
from_="+14158141829",
media_url="http://www.example.com/hearts.png")
print message.sid
然而,这似乎与django_twilio观点无关。