I spent the last two weeks (mostly working on my Applications presentation) thinking about what my ICM/PComp final should be. Since the beginning I knew I wanted to :
- build an immersive installation that makes the user to feel something that is shared live on social networks;
- use Twitter as a “switch” to activate a physical interface;
- use non technological material to build the installation;
- use those non technological material to build a “visualization” of data sent by Twitter.
My final will be called Interior Weather and is an interactive installation that transforms emotions shared live on Twitter into weather. The tweets containing:
- “I feel alone” will put the light of (darkness);
- “I feel sad” will activate water mist (rain);
- “I feel angry” will activate a thunder sound;
- “I feel happy” will turn the light on;
Connecting Processing to a Twitter stream
Today, I managed to connect Processing to a live stream using the Twitter API. It “println ” the tweets stream.
- You first need to activate your developer account on Twitter;
- Then you can connect to the API using this example.
// This is where you enter your Oauth info
static String OAuthConsumerKey = “put your key here”;
static String OAuthConsumerSecret = “put your secret here”;
// This is where you enter your Access Token info
static String AccessToken = “put your access token here”;
static String AccessTokenSecret = “put you token secret here”;
// if you enter keywords here it will filter, otherwise it will sample
String keywords[] = {“any keywords you want”
};
TwitterStream twitter = new TwitterStreamFactory().getInstance();
void setup() {
size(800, 600);
connectTwitter();
twitter.addListener(listener);
if (keywords.length==0) twitter.sample();
else twitter.filter(new FilterQuery().track(keywords));
}
void draw() {
background(0);
}
// Initial connection
void connectTwitter() {
twitter.setOAuthConsumer(OAuthConsumerKey, OAuthConsumerSecret);
AccessToken accessToken = loadAccessToken();
twitter.setOAuthAccessToken(accessToken);
}
// Loading up the access token
private static AccessToken loadAccessToken() {
return new AccessToken(AccessToken, AccessTokenSecret);
}
// This listens for new tweet
StatusListener listener = new StatusListener() {
public void onStatus(Status status) {
println(“@” + status.getUser().getScreenName() + ” – ” + status.getText());
}
}