8000 added twitter api script · simudream/python-scripts@1008c04 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1008c04

Browse files
committed
added twitter api script
1 parent f467a62 commit 1008c04

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

03_simple_twitter_manager.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import twitter
2+
3+
4+
TWITTER_CONSUMER_KEY = 'XXX'
5+
TWITTER_CONSUMER_SECRET = 'XXX'
6+
TWITTER_ACCESS_TOKEN_KEY = 'XXX'
7+
TWITTER_ACCESS_TOKEN_SECRET = 'XXX'
8+
9+
twitter_api = twitter.Api(
10+
consumer_key=TWITTER_CONSUMER_KEY,
11+
consumer_secret=TWITTER_CONSUMER_SECRET,
12+
access_token_key=TWITTER_ACCESS_TOKEN_KEY,
13+
access_token_secret=TWITTER_ACCESS_TOKEN_SECRET
14+
)
15+
16+
if __name__ == '__main__':
17+
follower_ids = twitter_api.GetFollowerIDs()
18+
following_ids = twitter_api.GetFriendIDs()
19+
zombie_follows = [following_id for following_id in following_ids if following_id not in follower_ids]
20+
21+
confirm = raw_input("Are you sure you want to unfollow %s tweeps [y|n]? " % (len(zombie_follows)))
22+
if confirm.lower() == 'y':
23+
for id in zombie_follows:
24+
user = twitter_api.DestroyFriendship(user_id=id)
25+
print "Unfollowed %s" % (user.screen_name)

readme.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
## Just another repo of Python scripts
22

33
1. **01_remove_all_pyc.md**: remove all *.pyc* files from a git repo
4-
2. **02_find_all_links.py**: get all links from a webpage
4+
2. **02_find_all_links.py**: get all links from a webpage
5+
3. **03_simple_twitter_manager.py**: accessing the Twitter API, example functions

0 commit comments

Comments
 (0)
0