Python Twitter与Tex转发

2024-10-01 15:42:25 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在建立一个机器人,可以转发一些文字。我想知道我们能不能用python-twitter用文字转发这篇文章。到目前为止,我目前的代码如下

import twitter
api = twitter.Api(consumer_key = '',
                  consumer_secret = '',
                  access_token_key = '',
                  access_token_secret = '') # opt-out the key here
# get example tweets ID from ``biorxivpreprint``
tweets = api.GetUserTimeline(screen_name="biorxivpreprint", count=10)

print(tweets[0])
>> Status(ID=1123256265176752129, ScreenName=biorxivpreprint, Created=Tue Apr 30 16:02:17 +0000 2019, 
          Text='Highly diverse fungal communities in carbon-rich aquifers of two contrasting lakes 
                in Northeast Germany ... #bioRxiv')

在这里,我们可以得到tweets ID的列表,然后我可以使用PostRetweet转发当前ID

 api.PostRetweet(1123256265176752129)

但是,我不知道如何使用python-twitter为转发添加文本。如果有人知道如何使用tweetpy,那也没关系!你知道吗


Tags: keyintokenapiidsecretaccessconsumer

热门问题