What do you need to install?
- Python
- Tweepy : Tweepy is a python library for accessing Twitter API.
- Developer account in Twitter
Steps
Create a test file name
test.py
in your working directory.Write the following here
import tweepy
# Consumer keys and access tokens from twitter developer console
CONSUMER_SECRET = '####'
CONSUMER_KEY = '###'
ACCESS_SECRET = '####'
ACCESS_KEY = '###'
# OAuth authentication connection from
auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
auth.set_access_token(ACCESS_KEY, ACCESS_SECRET)
# Creation of the actual interface, using authentication
tweet = tweepy.API(auth)
# Write tweet here
tweet.update_status("Hi from API" )
3.Run the following file by running python test.py
command in your working directory and bam, you are done in 8 lines of code.
Top comments (1)
Great snippets. Thanks for sharing!