forked from anthonydb/python-snippets
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtwitter-api-basic.py
More file actions
30 lines (23 loc) · 846 Bytes
/
Copy pathtwitter-api-basic.py
File metadata and controls
30 lines (23 loc) · 846 Bytes
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
# Hit the Twitter API and pull either the public timeline or a user
# timeline, and then print a selection of data.
# UTF-8 encoding is necessary especially when dealing with public
# timeline.
# Use the requests module
import twitter
api = twitter.Api(consumer_key='your-consumer-key',
consumer_secret='your-consumer-secret',
access_token_key='your-access-token-key',
access_token_secret='your-access-token-secret')
# set a handle
handle = 'anthonydb'
# Get some info on a user
user = api.GetUser(handle)
print user.GetName()
print user.GetFollowersCount()
print user.GetDescription()
# get a user timeline
statuses = api.GetUserTimeline('usatoday', count=1)
print [s.text for s in statuses]
# get a user timeline
#statuses = api.GetPublicTimeline()
#print [s.text for s in statuses]