1. Extend your P9 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
mulitple URLs, so you might again provide Next/Prev buttons to enable viewing
the various URLs one at a time.
Important enabling steps:
1. You need a twitter Developer account (https://developer.twitter.com/) for this
assignment.
2. Once you've done that you need to create/register a Twitter app. Do that here:
https://dev.twitter.com/apps
3. You need to be able to import some tools to enable pro perl 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:
1. Download modulesForOauth.zip.
2. Unzip the downloaded file (some computers/ Operating Systems do this
automatically). The folder is named 'modulesForOauth' DO NOT change the
name.
3. Move or copy the two folder into whatever folder contains your project9.py file.
Other important notes:
you should remove the center-of-map marker from project9. 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 39 (Dec. 4). Study the Search Tweets API reference
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 project10.
For the full project submit to ICON one zip file that contains a folder containing all of
the files that comprise your project10 solution (everything!, including the OAuth-related
folders)
GUI案例
2021-09-20