我使用python
使用以下代码
import tweepy, time, sys
argfile = str(sys.argv[1])
#enter the corresponding information from your Twitter application:
CONSUMER_KEY ='********'#keep the quotes, replace this with your consumer key
CONSUMER_SECRET ='*******'#keep the quotes, replace this with your consumer secret key
ACCESS_KEY ='*********'#keep the quotes, replace this with your access token
ACCESS_SECRET ='********'#keep the quotes, replace this with your access token secret
auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
auth.set_access_token(ACCESS_KEY, ACCESS_SECRET)
api = tweepy.API(auth)
filename=open(argfile,'r')
f=filename.readlines()
filename.close()
######
for line in f:
api.update_status(line)
time.sleep(900)#Tweet every 15 minutes
#### Code is ready
#### next to create the API for twitter
我希望发布的消息位于单独的文本文件中 -
HelloWorld.txt
Hello World!!!
Lots of Noise here
!!!!
I am tweeting. I wish to learn automation!!!!
最后一步涉及在命令行中使用以下命令
"helloworld.py" "HelloWorld.txt"
代码工作正常。 然而,推文不起作用。在授权机器人发推文后,我已经正确添加了密钥和密码。 如果有人能帮我理解这个错误,将不胜感激。