Twitter今天更新了其消息API(https://developer.twitter.com/en/docs/direct-messages/sending-and-receiving/api-reference/new-event),而我通过Tweepy编写的有关发送直接消息的所有Python代码均已停止工作,我似乎无法使其正常工作。这是我现在拥有的代码:
direct_message = api.send_direct_message(user=username, text=message_text)
但是,我从Twitter收到以下错误响应:
[{'code': 34, 'message': 'Sorry, that page does not exist.'}]
我对如何使用Tweepy实现新的API更改感到困惑。到今天为止,它的运行状况都很好,现在却无法正常工作。...我100%确定用户已通过身份验证,并且具有发送消息的权限,但我仍然遇到错误。
答案 0 :(得分:0)
更新Tweepy。在Twitter应用程序中检查对它的权限。撤消按键。 现在尝试这个简单的代码。
def direct_message(api):
logger.info("Start send mensage")
for dm in tweepy.Cursor(api.followers_ids).items(10):
#edit the msg parameter
api.send_direct_message(dm, 'Watching our new indie game trailer from my creator @AGTAStudios on Youtube : https://youtu.be/qGC-0toodmA')
logger.info("msg send")
def main():
api = create_api()
direct_message(api)
if __name__ == "__main__":
main()
如果它不起作用,请回复错误。
希望这会有所帮助。