无法使用 tweepy 向 Twitter 用户提供快速回复选项 (Python)
Can't give quick reply options to twitter user using tweepy (Python)
我想使用 Tweepy 库和 Twitter 的 API 在 Python 中发送带有快速回复选项的直接消息。 Tweepy 文档说我可以使用以下代码发送带有快速回复选项的 DM:
API.send_direct_message(recipient_id, text[, quick_reply_type][, attachment_type][, attachment_media_id])
我尝试通过使用 Python 创建我自己的选项来实现这一点,我是这样实现的:
import tweepy
import time
#login credentials need to be filled here
auth = tweepy.OAuthHandler('','')
auth.set_access_token('', '')
api = tweepy.API(auth)
user = api.get_user("user's name")
options = [
{
"label": "I'm good",
"description": "It means you're doing good",
"metadata": "external_id_1"
},
{
"label": "Not so good",
"description": "It means you're not doing good",
"metadata": "external_id_2"
}
]
direct_message = api.send_direct_message(user.id, "Hey Man! How's it going?", quick_reply_type=options)
我最终得到这个错误:
tweepy.error.TweepError: [{'code': 214, 'message': 'event.message_create.message_data.quick_reply: Unknown quick_reply type '}]
我什至尝试将选项设置为 Python 对象并使其 JSON 可序列化,但它仍然会给出相同的错误。我该怎么办?
这是 Tweepy 中的已知错误,已识别并修复(请参阅 Github 上的合并请求),但尚不可用。
在合并之前,唯一的选择似乎是在本地修复 Tweepy 并使用自定义版本。
我想使用 Tweepy 库和 Twitter 的 API 在 Python 中发送带有快速回复选项的直接消息。 Tweepy 文档说我可以使用以下代码发送带有快速回复选项的 DM:
API.send_direct_message(recipient_id, text[, quick_reply_type][, attachment_type][, attachment_media_id])
我尝试通过使用 Python 创建我自己的选项来实现这一点,我是这样实现的:
import tweepy
import time
#login credentials need to be filled here
auth = tweepy.OAuthHandler('','')
auth.set_access_token('', '')
api = tweepy.API(auth)
user = api.get_user("user's name")
options = [
{
"label": "I'm good",
"description": "It means you're doing good",
"metadata": "external_id_1"
},
{
"label": "Not so good",
"description": "It means you're not doing good",
"metadata": "external_id_2"
}
]
direct_message = api.send_direct_message(user.id, "Hey Man! How's it going?", quick_reply_type=options)
我最终得到这个错误:
tweepy.error.TweepError: [{'code': 214, 'message': 'event.message_create.message_data.quick_reply: Unknown quick_reply type '}]
我什至尝试将选项设置为 Python 对象并使其 JSON 可序列化,但它仍然会给出相同的错误。我该怎么办?
这是 Tweepy 中的已知错误,已识别并修复(请参阅 Github 上的合并请求),但尚不可用。
在合并之前,唯一的选择似乎是在本地修复 Tweepy 并使用自定义版本。