CS1210 Computer Science 1 - Fall 2021
Due Sunday, Dec. 12, by 8:00pm
1.Extend your HW10 program so that it displays a map showing locations of Twitter tweets matching
user-specific search terms.
The program should:
Important enabling steps:
- have a GUI that enables the user to enter a location and search terms
- query Twitter to gather tweets based on the search terms and the location.
- display a static map with markers showing the locations of the tweets returned by the search. For tweets that don't have specific geocode information, you may simply put a pin for that tweet in the center of the map. The marker for the currently displayed tweet should look different (e.g. different size and/or color) than markers for the other tweets.
- display the number of tweets retrieved
- display details of a "current" tweet and provide a way to "step through" each of the retrieved tweets:
- to step through tweets, you could provide, for example, "Next Tweet" and "Previous Tweet" buttons.
- for the current tweet, display at least the tweet text, and the screen name (e.g. @jimcremer) and name (e.g. James Cremer) of the user who created the tweet.
- for the current tweet, also provide a way to open a browser and display the web page corresponding to URLs embedded in the tweets. Twitter has alrady processed the tweet to find URLs - do NOT write code that looks through the text of the tweet. Use the 'media' and 'url' keys of the 'entities' field of the tweet object to get URLs. Some tweets contain multiple URLs, so you might again provide Next/Prev buttons to enable viewing the various URLs one at a time (but this is not required).
Other important notes:
- You need a twitter Developer account with "Elevated" access so that you can use Twitter API v1.1. See detailed step by step instructions here. It looks like a lot of steps but there are all simple and should take only a few minutes.
- Once you've done that you need to obtain API keys (to add to twitteraccess.py). Detailed instructions for obtaining the keys are here. This is a quick and easy process.
- You need to be able to import some tools to enable proper connection to Twitter using the Oauth secure authorization protocol. Rather than do full formal installation of the relevant tools, we will use a simpler approach for this assignment:
- Download modulesForOauth.zip.
- Unzip the downloaded file (some computers/operating systems do this automatically). The folder is named 'modulesForOauth' DO NOT change the name.
- Move or copy the folder into the same folder that contains your hw11.py file.
- you should remove the center-of-map marker from HW10. The only markers should be for retrieved tweets.
- make sure you include a call to authTwitter() in an appropriate place in your code!
- For searching Twitter, use (and modify) the sample Twitter code (twitteraccess.py).
Study the Search Tweets API reference (https://developer.twitter.com/en/docs/twitter-api/v1/tweets/search/overview) and detail about Tweet object JSON (https://developer.twitter.com/en/docs/tweets/data-dictionary/overview/tweet-object).
- In late 2017, Twitter extended the maximum length of tweets from 140 characters to 280 characters. The basic twitter API code provided in
twitteraccess.py does not retrieve JSON data containing full tweet text for tweets longer than 140 characters. Adding "&tweet_mode=extended" to
the query string constructed in searchTwitter *will* retrieve JSON data containing full tweet text up to 280 characters but the structure of the JSON object is slightly different. It is easy to modify your code to use this "extended tweet" JSON, but it is not REQUIRED for HW11.
For the full assignment submit to ICON one zip file that contains a folder containing all of the files that comprise your HW11 solution (everything!, including the OAuth-related folder)