forked from ideoforms/python-twitter-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
twitter-home-timeline.py
executable file
·34 lines (28 loc) · 1.49 KB
/
twitter-home-timeline.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/python
#-----------------------------------------------------------------------
# twitter-hoome-timeline:
# - uses the Twitter API and OAuth to log in as your username,
# and lists the latest 50 tweets from people you are following
#-----------------------------------------------------------------------
from twitter import *
#-----------------------------------------------------------------------
# load our API credentials
#-----------------------------------------------------------------------
config = {}
execfile("config.py", config)
#-----------------------------------------------------------------------
# create twitter API object
#-----------------------------------------------------------------------
twitter = Twitter(
auth = OAuth(config["access_key"], config["access_secret"], config["consumer_key"], config["consumer_secret"]))
#-----------------------------------------------------------------------
# request my home timeline
# twitter API docs: https://dev.twitter.com/rest/reference/get/statuses/home_timeline
#-----------------------------------------------------------------------
statuses = twitter.statuses.home_timeline(count = 50)
print statuses
#-----------------------------------------------------------------------
# loop through each of my statuses, and print its content
#-----------------------------------------------------------------------
for status in statuses:
print "(%s) @%s %s" % (status["created_at"], status["user"]["screen_name"], status["text"])