In order to access Twitter APIs, we need to get 4 pieces of information from Twitter: API key, API secret, Access token and Access token secret. Follow the steps below to get all 4 elements:
- Create a twitter account if you do not already have one.
- Go to https://apps.twitter.com/ and log in with your twitter credentials.
- Click "Create New App"
- Fill out the form, agree to the terms, and click "Create your Twitter application"
- In the next page, click on "API keys" tab, and copy your "API key" and "API secret".
- Scroll down and click "Create my access token", and copy your "Access token" and "Access token secret".
- Now store these values in API_DATA.py file in SentimentAnalysisModule folder.(Format given in sample file)
-
Run the script indiaagainstcorruption.py using the command.
$ python hashtag.py search_term _hashtag
Note: append '_' with a hashtag you want to search for. -
See the output in
hashtag
_tweet.json