A simple python twitter client
Install the gem
Proceed to install the required library with pip install python-twitter
as indicated at https://github.com/bear/python-twitter.
Sample code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import twitter
import sys
import time
import datetime
try:
api = twitter.Api(
consumer_key='THE_CONSUMER_KEY',
consumer_secret='THE_CONSUMER_SECRET',
access_token_key='THE_ACCESS_TOKEN_KEY',
access_token_secret='THE_ACCESS_TOKEN_SECRET'
)
lines = [line.rstrip('\n') for line in open(sys.argv[1]) if line != '\n']
for line in lines:
api.PostUpdates(line)
print "[*] At %s tweeted: %s" % (datetime.datetime.now().isoformat(), line)
time.sleep(60*20) # this is for delay the post updates tweets for 20 minutes
except Exception, e:
print e