Twilio API / TWIML 当用户响应我的文本(通过文本)并且我收到他们对我的端点的回答时,我如何识别发件人?
起初我以为它是“sid”,但事实并非如此。我找不到“发送”和“响应”中都存在的“conversation_id”,它可以提醒我的终点是谁发件人。
当我从服务器发送文本时,响应如下所示:
{ sid: 'MMf9...',
date_created: 'Thu, 18 Aug 2016 03:24:50 +0000',
date_updated: 'Thu, 18 Aug 2016 03:24:50 +0000',
date_sent: null,
account_sid: '...',
to: '...,
from: '...',
messaging_service_sid: '...',
body: 'Hi. this is an anonymous text from my server',
status: 'accepted',
num_segments: '1',
num_media: '1',
direction: 'outbound-api',
api_version: '2010-04-01',
price: null,
price_unit: null,
error_code: null,
error_message: null,
uri: '/2010-04-01/Accounts/...../Messages/......json',
subresource_uris: { media: '/2010-04-01/Accounts/...../Messages/...../Media.json' },
dateCreated: Thu Aug 18 2016 03:24:50 GMT+0000 (UTC),
dateUpdated: Thu Aug 18 2016 03:24:50 GMT+0000 (UTC),
dateSent: null,
accountSid: '....',
messagingServiceSid: '.....',
numSegments: '1',
numMedia: '1',
apiVersion: '2010-04-01',
priceUnit: null,
errorCode: null,
errorMessage: null,
subresourceUris: { media: '/2010-04-01/Accounts/..../Messages/..../Media.json' } }
当我将手机中的文本回复到服务器时,我的端点会收到...
{
"ToCountry": "US",
"ToState": "IL",
"SmsMessageSid": "SMe....",
"NumMedia": "0",
"ToCity": "Chicago",
"FromZip": "60626",
"SmsSid": "SMe....",
"FromState": "IL",
"SmsStatus": "received",
"FromCity": "CHICAGO",
"Body": "Try",
"FromCountry": "US",
"To": "....",
"MessagingServiceSid": "....",
"ToZip": "",
"NumSegments": "1",
"MessageSid": "SMe...",
"AccountSid": "...",
"From": "...",
"ApiVersion": "2010-04-01"
}
如您所见,原始短信中的 sid 以 MMf9 开头...而我手机响应中的所有 id 都以 SMe 开头...
我希望在发送和响应中存在一些对话 ID,以便在我的端点上,我可以为对话创建一个数据库条目,并存储我的用户从对话中的响应。但是现在由于发送者和接收者之间没有对话 ID,我不知道在哪里存储对话,也不知道我的服务器正在向谁发送响应。