Step 5: Twitter Code
2. Get set up to pull data from twitter. We used the Python Twitter Library to simplify the Twitter connection process. In order to connect to Twitter and obtain data you need to register a Twitter application at http://dev.twitter.com/. This will give you ‘consumer’ and ‘access’ ‘keys’ and ‘tokens’ you need to successfully connect.
3. The next step is to collect the latitudes and longitudes of the cities that you want to collect data for. In our case we collected the locations for 10 Colorado metropolitan areas.
4. Decide what kind of information you want to display. In our case we decided that we would display the relative happiness for each location. To accomplish this we compiled a list of ‘happy’ an ‘unhappy’ words. We then perform two Twitter searches, using the api, for each location every 60 seconds. One for the happy and one for the unhappy words.
5. Its up to you to determine how this information will correlate to different colors for the LEDs on the map. In our case, there were a lot more happy results than unhappy results. So only a few unhappy results were required to make a location ‘unhappy.
All of our code for this project can be found at: https://github.com/ianisborn/TTT/tree/master/sandbox