我已经做了很多工作,这是使聊天机器人正常工作的最后一件事。我试图在我的WhatsApp聊天机器人上从用户收到图像(自拍照),但没有成功。我在Django中使用Python。
TypeError: __init__() takes 2 positional arguments but 4 were given
起初我尝试过类似的事情:
@twilio_view
def visita_selfie(request):
print('VISITA SELFIE')
message_sid = request.POST.get('MessageSid', '')
from_number = request.POST.get('From', '')
num_media = int(request.POST.get('NumMedia', 0))
media_files = [(request.POST.get("MediaUrl{}".format(i), ''),
request.POST.get("MediaContentType{}".format(i), ''))
for i in range(0, num_media)]
print('media files')
print(media_files)
memory = json.loads(request.POST.get('Memory'))
print('Memory= ',memory)
return HttpResponse(status=200)
但这没用。
我的日志上什么也没有,Twilio调试器向我显示了
{
"actions": [
{
"say": "Please send me the selfie."
},
{
"listen": true
},
{
"redirect" : "my webhook"
}
]
}
然后我尝试了Collect:
Request Inspector
- Collapse All
POST
https://channels.autopilot.twilio.com/v1/AC0de44f5c63d50ab672ae85bef67ff3bc/UA313a4235eb1ee7cc39ce2ec1781d911a/twilio-messaging/whatsapp
2019-11-12 17:54:05 UTC
400
Request
URL
https://channels.autopilot.twilio.com/v1/AC0de44f5c63d50ab672ae85bef67ff3bc/UA313a4235eb1ee7cc39ce2ec1781d911a/twilio-messaging/whatsapp
Parameters
Show Raw
ApiVersion
"2010-04-01"
MediaUrl0
"https://api.twilio.com/2010-04-01/Accounts/AC0de44f5c63d50ab672ae85bef67ff3bc/Messages/MMd9aa12480e0bebd90ace8a8d5e46cca9/Media/MEaf6ae55ca8c5b27defdef15698a182f8"
SmsSid
"MMd9aa12480e0bebd90ace8a8d5e46cca9"
SmsStatus
"received"
SmsMessageSid
"MMd9aa12480e0bebd90ace8a8d5e46cca9"
NumSegments
"1"
From
"whatsapp:+553584311599"
To
"whatsapp:+14155238886"
MessageSid
"MMd9aa12480e0bebd90ace8a8d5e46cca9"
Body
""
AccountSid
"AC0de44f5c63d50ab672ae85bef67ff3bc"
NumMedia
"1"
MediaContentType0
"image/jpeg"
Message Text
Show Raw
Msg
"Bad Request"
sourceComponent
"14100"
ErrorCode
"11200"
EmailNotification
"false"
httpResponse
"400"
LogLevel
"ERROR"
url
"https://channels.autopilot.twilio.com/v1/AC0de44f5c63d50ab672ae85bef67ff3bc/UA313a4235eb1ee7cc39ce2ec1781d911a/twilio-messaging/whatsapp"
Response
Headers
X-Cache MISS from Twilio-Cache
X-Cache-Lookup MISS from Twilio-Cache:3128
X-Twilio-WebhookAttempt 1
X-Twilio-WebhookRetriable false
Content-Length 66
Date Tue, 12 Nov 2019 17:54:06 GMT
Content-Type application/json
Body
Show Raw
{
"code": 20001,
"status": 400,
"message": "Missing/Invalid Parameters"
}
我也不工作,当我用collect键入文本时,我的日志只显示了'VISITA SELFIE'(意味着它已到达功能),但是media_files为空[]。
我在做什么错了?
答案 0 :(得分:0)
这里是Twilio开发人员的传播者。
恐怕Twilio Autopilot doesn't support media right now,所以您将无法像这样从网络挂钩中获取图像。