Python 使用Tweepy更新Twitter直接消息API

Python 使用Tweepy更新Twitter直接消息API,python,twitter,tweepy,Python,Twitter,Tweepy,Twitter今天更新了他们的messagesapi(),我通过Tweepy编写的所有与发送直接消息相关的Python代码都停止了工作,我似乎无法让它工作。这是我现在掌握的代码: direct_message = api.send_direct_message(user=username, text=message_text) 但是,我从Twitter收到以下错误响应: [{'code': 34, 'message': 'Sorry, that page does not exist.'}]

Twitter今天更新了他们的messagesapi(),我通过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%确定该用户已通过身份验证,并且有权发送消息,但我仍然收到错误。

更新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()
如果它不工作,回答错误


希望这有帮助。

看起来tweepy当前没有更新以支持新的端点。有一些可能会对你有所帮助,但在库更新之前,它不会很简单。我也有同样的问题。我们需要等待tweepy更新:-(您是否检查了GitHub上提供的此解决方案?