-from api import Twitter
-from cmdline import CONSUMER_KEY, CONSUMER_SECRET
-from oauth import read_token_file, OAuth
+def get_tweets(twitter, screen_name, max_id=None):
+ kwargs = dict(count=3200, screen_name=screen_name)
+ if max_id:
+ kwargs['max_id'] = max_id
+
+ n_tweets = 0
+ tweets = twitter.statuses.user_timeline(**kwargs)
+ for tweet in tweets:
+ if tweet['id'] == max_id:
+ continue
+ print("%s %s\nDate: %s" % (tweet['user']['screen_name'],
+ tweet['id'],
+ tweet['created_at']))
+ if tweet.get('in_reply_to_status_id'):
+ print("In-Reply-To: %s" % tweet['in_reply_to_status_id'])
+ print()
+ for line in tweet['text'].splitlines():
+ printNicely(' ' + line + '\n')
+ print()
+ print()
+ max_id = tweet['id']
+ n_tweets += 1
+ return n_tweets, max_id