Starter code used for live demo of integrating the Twitter API and Python for EECS 398 Winter 2018 at University of Michigan, Ann Arbor
$ pip3 install tweepy
-
created specifically to pull data from Twitter
-
no need to index into large dictionaries or format request URLs
pip3 install matplotlib
-
good for plotting data
-
"not the best out there, but easy to use" - Amrit
-
you want to keep your API keys secret, which is why they are placed in a separate file from your program.
-
if you choose to put your project on GitHub, DO NOT commit
secret.py
Go to https://apps.twitter.com
-
sign into Twitter, then click "Create New App" in the upper right
-
fill out the name, description, and website for your applicaiton. Check the "Developer Agreement" box and finish creating your app!
-
under the name of your application, find and click the "Keys and Access Tokens" tab
-
located under Applicaiton Settings
-
copy and paste these keys into
secret.py
-
scroll down and click "Authorize my Application"
-
located under "Your Access Token"
-
copy and paste these keys into
secret.py
-
import tweepy
-
import matplotlib
-
from secret import *
-
check out the tweepy documentation on getting started
-
use keys/tokens from
secret.py
to create the session
- ask the user (you) what hashtag to search
-
create new Tweet objects for each result
-
we only need the time each tweet was posted, but other data may be useful for debugging or other data analysis
-
check out the matplotlib documentation on histograms and subplots
-
this is just one analysis you could do on Twitter data
-
try something on your own!