24
loading...
This website collects cookies to deliver better user experience
credentials.py
and store these four keys in the key-value format as shown below:access_token="XXXXXXX"
access_token_secret="XXXXXXXX"
API_key="XXXXXXX"
API_secret_key="XXXXXXXX"
import tweepy
# Authenticate to Twitter
auth = tweepy.OAuthHandler("CONSUMER_KEY", "CONSUMER_SECRET")
auth.set_access_token("ACCESS_TOKEN", "ACCESS_SECRET")
api = tweepy.API(auth)
try:
api.verify_credentials()
print("Authentication Successful")
except:
print("Authentication Error")
Tweepy is an open-sourced, easy-to-use Python library for accessing the Twitter API. It gives you an interface to access the API from your Python application.
pip install tweepy
pip install git+https://github.com/tweepy/tweepy.git
OAuthHandler
class that takes care of the OAuth required by Twitter to authenticate API calls.user = api.get_user('apoorv__tyagi')
print(user.screen_name) #User Name
print(user.followers_count) #User Follower Count