Would also recommend twitter4j as default option, but if you're just going to use the twitter search API, you don't need to go through the hassle of creating some OAuth credentials. Also, JSON is just one of the possible output formats, another one is
Atom. For for the latter you can use my toxiclibs which build on
JAXB and have basic support for Atom feeds built in:
- import toxi.data.feeds.*;
- String atomURL="http://search.twitter.com/search.atom?q=%23processing";
- AtomFeed feed=AtomFeed.newFromURL(atomURL);
- println(feed.entries.size()+" entries loaded");
- for(AtomEntry e : feed) {
- println(String.format("[%s] %s", e.author.name, e.title));
- }
You can use the
advanced search tool on twitter to construct more complex search queries (without authentication) and then grab the feed url from the results page...
Also, here're a few other forum threads about twitter4j:
More generally, and maybe not in the case of twitter (since there's twitter4j), but if you do have to use JSON, then I'd recommend using the Jackson libraries...
Hth!
http://postspectacular.com |
http://toxiclibs.org