Created
June 3, 2014 22:51
-
-
Save ET-CS/0bc1f58f4b954c1f06e9 to your computer and use it in GitHub Desktop.
Get Twitter Followers in Python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import twitter | |
from twitter import TwitterError | |
TWITTER_CONSUMER_KEY = 'your consumer key' | |
TWITTER_CONSUMER_SECRET = 'your consumer secret' | |
TWITTER_ACCESS_TOKEN_KEY = 'your token key' | |
TWITTER_TOKEN_SECRET = 'your token secret' | |
def get_twitter_followers(): | |
try: | |
api = twitter.Api( \ | |
consumer_key=TWITTER_CONSUMER_KEY, \ | |
consumer_secret=TWITTER_CONSUMER_SECRET, \ | |
access_token_key=TWITTER_ACCESS_TOKEN_KEY, \ | |
access_token_secret=TWITTER_TOKEN_SECRET) | |
except TwitterError: | |
# do something on error (like on twitter read limit) | |
return api.VerifyCredentials().followers_count |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment