使用 python/Tweepy 从 Twitter 获取最新的直接消息 [英] Get latest direct message from Twitter using python/Tweepy

查看:32
本文介绍了使用 python/Tweepy 从 Twitter 获取最新的直接消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚开始使用 Tweepy,我正在尝试构建一个非常简单的机器人,它将使用 Twitter 来自动化我家中的一些事情(主要是为了好玩和学习 Tweepy).我浏览了 Tweepy 文档,但不知道如何在不知道消息 ID 的情况下从我自己的帐户中检索最新的直接消息.

I've just started using Tweepy and I'm trying to build a pretty simple bot that will use Twitter to automate a few things in my home (mostly for fun and to learn Tweepy). I've gone through the Tweepy docs and can't find out how to retrieve the latest direct message from my own account without knowing the message ID.

我假设我可以使用 API.get_direct_messages() 方法,但它需要一个消息 ID(我不知道).谁能告诉我正确的方法来做到这一点?我正在使用 Python3

I'm assuming I can use the API.get_direct_messages() method but it requires a message ID (which I don't know). Can anyone clue me in to the proper way to do this? I'm using Python3

谢谢!

推荐答案

您似乎混淆了两种不同的方法.direct_messages() 方法(没有 get_)应该给你一个直接消息列表.

You seem to have confused two different methods. The direct_messages() method (without get_) should give you a list of direct messages.

get_direct_message()(单数)从其 ID 返回一条直接消息.

get_direct_message() (singular) returns a single direct message from its ID.

这篇关于使用 python/Tweepy 从 Twitter 获取最新的直接消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆