access twitter api using tweepy in python 1

access twitter api using tweepy in python

import tweepy
consumer_key= 'your consumer_key'
consumer_secret= 'your consumer_key_secret'
access_token= 'your access_token'
access_token_secret= 'your access_token_secret'
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token,access_token_secret)
api = tweepy.API(auth)
#From here, you can tweet, search tweets, search keywords, etc.

Here is what the above code is Doing:
1. We are importing the tweepy library.
2. We are setting the consumer_key, consumer_secret, access_token, and access_token_secret.
3. We are using the OAuthHandler method to authenticate our app.
4. We are using the set_access_token method to set the access token and access token secret.
5. We are using the API method to create an API object.

Similar Posts