Wednesday, July 29, 2009

Integrate Twitter and bit.ly into your Java App

I am in the final stage of developing towards the 2.0 release of jRecruiter. It is the job posting service of the Atlanta Java Users Group (AJUG) and as such I devote some of my spare-time towards it. It is a great way to explore all kinds of different technologies. Thus, last weekend I had the idea that it might be a cool idea to let the system "tweet" about job posting additions and updates. Here are my findings.

First I looked at available Twitter libraries for Java:
After some considerations, I chose Twitter4J. To me, it seemed to be the most active of the three projects. Even better, it has a BSD-style license. Using Twitter4J is super simple:

Twitter twitter = new Twitter("username", "password");

try {
twitter.updateStatus("My tweet");
} catch (TwitterException e) {

}

There is so much more you can with Twitter4J. Check out its documentation for further details.

Secondly, as each tweet contains a link back to the job detail page in the main application, I was looking into ways to shorten URLs. That way, I can store more job posting related data within the only 140 characters available for each Twitter status update.

The original service for this is TinyURL. However, it looks like bit.ly has more traction these days and is also used directly by Twitter itself. The nice thing about bit.ly is that they have developer accounts and are offering a web service API for doing URL shortening.

Even better, there is already a Java library available for using bit.ly called bitlyj. Using bitlyj is actually almost as equally simple to use as Twitter4j:

final Bitly bitly =
BitlyFactory.newInstance("username", "your_bitly_api_key");
try {
BitlyUrl bUrl = bitly.shorten("http://www.google.com/");
URL url = bUrl.getShortUrl();
} catch (IOException e) {

}

Unfortunately, you have to build bitlyj yourself, but thanks to Maven it is a piece of cake. One thing I noticed, is that the error handling of the library could be more robust. Accidentally, I was using my bit.ly password, initially. However, bit.ly provides an API Key. By the way if you ever wonder where you can get that API Key-It is right in your account page. Anyway, the library needs some attention but for my simple use-case it worked fine.

Labels: , ,

Thursday, July 23, 2009

MapReduce, Hadoop and Cascading at AJUG

Yesderday Chris Curtin, CTO at Silverpop, gave an awesome presentation on MapReduce, Hadoop and Cascading. I really enjoyed his wealth of real-world practical examples.

His presentation is available at: http://www.slideshare.net/chriscurtin
Thanks to John Willis, there is also a video recording available at: http://www.johnmwillis.com/ec2/hadoop-and-cascading-ajug-072109/

Labels: ,