TweetPony 筆記


1
2
3
4
5
virtualenv --no-site-package --python=python2.7 venv
. venv/bin/activate
which python

pip install tweetpony
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/usr/bin/env python

import tweetpony

# Get from dev.twitter.com by create app and generate access token
api = tweetpony.API(
consumer_key = "YOUR KEY",
consumer_secret = "YOUR SECRET",
access_token = "YOUR TOKEN",
access_token_secret = "YOUR SECRET"
)

print("User: {0}".format(api.user.screen_name))
print("===" * 10)

# Using the endpoint method from endpoint.py
# - https://github.com/Mezgrman/TweetPony/blob/master/tweetpony/endpoints.py
for timeline in reversed(api.user_timeline(include_rts=False)):
print("{0} {1}".format(
timeline.id,
timeline.text.encode("utf8")
))