Homework 11
CS2110, Spring 2021
Due Sunday, May 9, 5pm
7 points
1.Extend your HW10 program so that it displays a map showing locations of Twitter tweets matching
user-specific search terms.
The program should:
- 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. Some tweets contain multiple URLs, so you might again provide Next/Prev buttons to enable viewing the various URLs one at a time.
Important enabling steps:
- You need a twitter Developer account (https://developer.twitter.com/) for this assignment.
- Once you've done that you need to create/register a Twitter app. Do that here: https://dev.twitter.com/apps
- 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 whatever folder contains your hw11.py file.
Other important notes:
- 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) provided with Lecture 41 (Apr. 30).
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)