Another member of the group retrieved the twitter API. We were provided with a consumer key, consumer secret, access token and access token secret which were all needed for the code.
We followed a tutorial on Codasign, which took us through each step to create the code. Unlike the instagram one, we required a library to add onto processing. The twitter 4j library allowed us to use twitter’s API in processing. This was downloaded and then imported at the top of the sketch.
Outside the setup, the variables were declared. In this case, the ‘string’/ text was declared. The code would then search twitter for any tweets containing “digital art” (this could be changed or look for multiple search terms). The int holds numbers and holds the number of current tweets. The tweets are stored in these until the draw.
Within the set up, the consumer key etc was needed to search through twitter. The setup was also where the functions happened, and it allowed the tweets to be retrieved before drawing them in the draw.
The functions are outside the draw, and this was the function that searched twitter and got the tweets.
The next function refreshed the tweets and got new ones, while it was already getting the original tweets, so it is constantly loading and retrieving new tweets. The delay is 30 seconds, so it only refreshes and gets the updated tweets after 30 seconds.
The draw then takes the tweets and displays them one at a time, fading in and out at random positions on the screen. They change and reload to new ones after 30 seconds. (The delay can be changed so that the tweets are refreshed quicker.
The if statement controls the refreshing of the tweets in the draw. It constantly goes back to zero so it starts to draw them over again.
When the code runs it is displayed like this:
The display of the tweets is similar to what we wanted. We just needed to combine the instagram and twitter codes together. As we decided instead of separate projections of instagram and twitter we were going to use one projection and one sketch.
Codasign. (2016) Processing and Twitter. [Online] Available from: http://codasign.com/tutorials/processing-and-twitter/processing-and-twitter-getting-started/ [Accessed 7th March 2016]