Skip to content

Instantly share code, notes, and snippets.

@nonchip
Last active September 25, 2016 17:58
Show Gist options
  • Save nonchip/a115dbc7353b7eac83497158d1f0b2af to your computer and use it in GitHub Desktop.
Save nonchip/a115dbc7353b7eac83497158d1f0b2af to your computer and use it in GitHub Desktop.
Python_stuff
import tweepy
f=open(".keys","r")
consumer_key=f.readline().rstrip().split()[0]
consumer_secret=f.readline().rstrip().split()[0]
access_token=f.readline().rstrip().split()[0]
access_token_secret=f.readline().rstrip().split()[0]
f.close()
auth = tweepy.OAuthHandler(consumer_key,consumer_secret)
if access_token == "":
print(auth.get_authorization_url())
print("now go to the url and paste the generated key back here.")
auth.get_access_token(input())
f=open(".keys","a")
f.write(auth.access_token+"\n")
f.write(auth.access_token_secret+"\n")
f.close()
else:
auth.set_access_token(access_token, access_token_secret)
api = tweepy.API(auth)
public_tweets = api.home_timeline()
for tweet in public_tweets:
print tweet.text
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment