forked from ideoforms/python-twitter-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtwitter-oauth-timeline.py
More file actions
executable file
·28 lines (22 loc) · 1.1 KB
/
twitter-oauth-timeline.py
File metadata and controls
executable file
·28 lines (22 loc) · 1.1 KB
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
#!/usr/bin/python
#-----------------------------------------------------------------------
# twitter-oauth-timeline:
# - uses the Twitter API and OAuth to log in as your username,
# and lists the latest 50 tweets from your feed.
#-----------------------------------------------------------------------
from twitter import *
# these tokens are necessary for user authentication
# (created within the twitter developer API pages)
consumer_key = "XxXxXxxXXXxxxxXXXxXX"
consumer_secret = "xXXXXXXXXxxxxXxXXxxXxxXXxXxXxxxxXxXXxxxXXx"
access_key = "XXXXXXXX-xxXXxXXxxXxxxXxXXxXxXxXxxxXxxxxXxXXxXxxXX"
access_secret = "XxXXXXXXXXxxxXXXxXXxXxXxxXXXXXxXxxXXXXx"
# create twitter API object
auth = OAuth(access_key, access_secret, consumer_key, consumer_secret)
twitter = Twitter(auth = auth)
# request my home timeline
# twitter API docs: https://dev.twitter.com/docs/api/1/get/statuses/home_timeline
statuses = twitter.statuses.home_timeline(count = 50)
# 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"])