【发布时间】:2017-08-26 21:47:57
【问题描述】:
我正在用 Python 构建一个 Facebook Messenger 机器人,但我的快速回复脚本无法正常工作,尽管我已经知道如何发送简单的文本消息和通用模板。到目前为止,这是我的代码:
这个有效:
text = {
"recipient": {
"id": user_id
},
"message": {
"text": "some text"
}
}
这个没有:
question = {
"recipient": {
"id": user_id
},
"message": {
"quick_replies": [{
"content_type": "location"
# "title": "RED",
# "text": "red",
# "payload": "red"
}]
}
}
两者都发布:
headers={"Content-Type": "application/json"}
requests.post('url', data = json.dumps(text), headers=headers)
requests.post('url', data = json.dumps(question), headers=headers)
在示例中,标题、文本和有效负载都被注释了,因为我试图使脚本与位置一样基本的东西一起工作......但我不断收到“问题”的响应 400; “文本”工作得很好。
【问题讨论】: