Created
June 17, 2019 23:58
-
-
Save martin-martin/2f977381452a715dc9bae82a0ef3c34a to your computer and use it in GitHub Desktop.
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 os | |
import tweepy | |
# fetch the secrets from our virtual environment variables | |
CONSUMER_KEY = os.environ['TWITTER_CONSUMER_KEY'] | |
CONSUMER_SECRET = os.environ['TWITTER_CONSUMER_SECRET'] | |
ACCESS_TOKEN = os.environ['TWITTER_ACCESS_TOKEN'] | |
ACCESS_SECRET = os.environ['TWITTER_ACCESS_SECRET'] | |
# authenticate to the service we're accessing | |
auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET) | |
auth.set_access_token(ACCESS_TOKEN, ACCESS_SECRET) | |
# create the connection | |
api = tweepy.API(auth) | |
# define a handle to inspect | |
handle = 'twitter' # for example purposes; use any handle you want! | |
# fetch user object and friend count | |
user = api.get_user(handle) | |
num_friends = user.friends_count |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment