added twitter api script
This commit is contained in:
parent
f467a62416
commit
1008c04851
25
03_simple_twitter_manager.py
Normal file
25
03_simple_twitter_manager.py
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
import twitter
|
||||||
|
|
||||||
|
|
||||||
|
TWITTER_CONSUMER_KEY = 'XXX'
|
||||||
|
TWITTER_CONSUMER_SECRET = 'XXX'
|
||||||
|
TWITTER_ACCESS_TOKEN_KEY = 'XXX'
|
||||||
|
TWITTER_ACCESS_TOKEN_SECRET = 'XXX'
|
||||||
|
|
||||||
|
twitter_api = twitter.Api(
|
||||||
|
consumer_key=TWITTER_CONSUMER_KEY,
|
||||||
|
consumer_secret=TWITTER_CONSUMER_SECRET,
|
||||||
|
access_token_key=TWITTER_ACCESS_TOKEN_KEY,
|
||||||
|
access_token_secret=TWITTER_ACCESS_TOKEN_SECRET
|
||||||
|
)
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
follower_ids = twitter_api.GetFollowerIDs()
|
||||||
|
following_ids = twitter_api.GetFriendIDs()
|
||||||
|
zombie_follows = [following_id for following_id in following_ids if following_id not in follower_ids]
|
||||||
|
|
||||||
|
confirm = raw_input("Are you sure you want to unfollow %s tweeps [y|n]? " % (len(zombie_follows)))
|
||||||
|
if confirm.lower() == 'y':
|
||||||
|
for id in zombie_follows:
|
||||||
|
user = twitter_api.DestroyFriendship(user_id=id)
|
||||||
|
print "Unfollowed %s" % (user.screen_name)
|
@ -2,3 +2,4 @@
|
|||||||
|
|
||||||
1. **01_remove_all_pyc.md**: remove all *.pyc* files from a git repo
|
1. **01_remove_all_pyc.md**: remove all *.pyc* files from a git repo
|
||||||
2. **02_find_all_links.py**: get all links from a webpage
|
2. **02_find_all_links.py**: get all links from a webpage
|
||||||
|
3. **03_simple_twitter_manager.py**: accessing the Twitter API, example functions
|
Loading…
Reference in New Issue
Block a user