lundi 31 janvier 2011

Processing and Twitter

Of course, just when twitter is working in Flash, somebody wants it in Processing.

http://tinkerlondon.com/now/2010/09/14/oauth-twitter-and-processing/
http://twitter4j.org/en/index.html#download

The most difficult thing is to get the Processing lib right (wrong?). 

But do we really need this?
Couldn't we call the same PHP file we used in the last FLASH script?

Better still, there is XMLElement in Processing:


XMLElement xml;

void setup() {
size(800, 480);
xml = new XMLElement(this, "http://twitter.com/statuses/user_timeline/111370674.rss");
}

void draw() {

println( " number of xml children " + xml.getChildCount() );

XMLElement myChannel = xml.getChild(0);
println( " number of xml children " + myChannel.getChildCount() );

XMLElement[] tweets = myChannel.getChildren("item");

for (int i = 0; i < tweets.length; i++) { fill(0); textSize(9);

println(i + " " + tweets[i].getChild(0) ); 
text( tweets[i].getChild(0).getContent() , 10, 20 + i*30); 
} noLoop(); 
}

Aucun commentaire:

Enregistrer un commentaire