Creating a twitter app with python



Head to the following link and follow the instructions below. You will need access to a twitter account, and have a github account to view the posted code.

  • install pip by running: python
  • install tweepy by running: Sripts\pip install tweepy

Code for Notepad:
Create a file called ‘YourName’

Ensure that you put the hashtags (#) in front of the lines that have it as it is there to clarify the purpose of the code that follows

import tweepy

# enter your authentication details below (see

consumer_key = ”
consumer_secret = ”
access_token = ”
access_token_secret = ”

# create authentication token

auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)

# get API handler

api = tweepy.API(auth)

# get text to tweet – should add error check for tweet lengthtweet = raw_input( “Enter text to tweet: ” )

print “Sending tweet “, tweet
api.update_status(‘Tweet via python #CodeSaints: ‘+ tweet)

Leave a Reply