Twitter + Processing + OSC
Processing twitter tutorialHave you ever wanted to integrate Twitter inside Processing? Using twitter4J, this can be easily achieved within 5 minutes! Firstly head to developer.twitter.com, log in, go to ‘My Applications’ and create a new application. You should then see a screen as follows:
Take a note of the Consumer key and Consumer secret, and then click on ‘Create my access token’ to reveal Access token and Access token secret.
Now open up Processing, and import twitter4J by dragging and dropping the file twitter4j-core-3.0.3.jar from /twitter4J/libs (which should be saved to /processing/libraries) onto the sketch. You can verify that the library is loaded by checking the sketch folder and looking in the code folder which should contain a copy of twitter4j-core-3.0.3.jar.
Next create a ConfigurationBuilder object using Consumer key, Consumer secret, Access token, and Access token secret as from your Twitter application
where “insert consumer key” etc. are replaced by the values from your Twitter application. Next, a Twitter object and query can be created using
and these results can be printed to the console using
At this point we have a functioning Twitter integration inside Processing. Now lets do something fun with this information. Download oscP5 to /Processing/Libraries, import it, and create the following global variables
which can be instantiated using
and then add the following two methods, mousePressed() which sends the message /test helloworld on every mouse click, and the event handler oscEvent() which prints to the console the contents of the received messages
Finally here is a simple example which checks for new #life tags every 12 seconds, and for each new status received, outputs an OSC message to a software instrument to play a new piano note. Prefer openFrameworks? Then take a look at ofxTwitter, same principle applies.