Wednesday, August 19, 2009

Post Twitter updates from delivers

A few days ago I read on a blog a question about posting to Twitter from Delivers via the advanced tab. So I ventured to try this myself and here are my results. It's very cool to be able to send Twitter updates via Delivers since this would essentially leverage Twitter's ability to notify both email and phone devices (iphone/blackberry/etc) with little to no hassle. I'm not going to get into the details on how to build the Java class, but here's how I did it:

I used Twitter4J as my library to log-in and post Twitter updates. I could create my own URL wrappers but why re-invent the lemonade right? so go and grab a copy of Twitter4J from http://yusuke.homeip.net/twitter4j/en/index.html and use your favorite IDE (I used Eclipse) to create your java class.

In order to pass the Twitter username and password I used the parameter values that you can setup in the Advanced tab of the iBot creation wizard. Then I referenced those two parameters within my java class like so:

Twitter twitter = new Twitter(jobInfo.parameter(0),jobInfo.parameter(1));

For the content to post, I used a modified version (removed HTML tags) of the Corporate Overview sample that is included with the Paint dashboard sample (Shared Folders/Paint Demo/Sales Summaries/Regional Analysis/Corporate Overview) which is a narrative view. I modified it and saved it to "My Folders". This is the text that will be posted to Twitter.

I setup the iBot as follows:
  • Class Name: com.kerdock.delivers.DeliversToTwitter (the name of my Java class)
  • ClassPath: kdqobiee.jar (the name of the jar containing the above class)
  • Additional Class Path(s): twitter4j.jar (downloaded from the URL referenced above)
  • Results: Pass delivery content to Java Program
  • Other Parameters: two parameters containing my twitter username and password


Then I copied the jars (kdqobiee.jar and twitter4j.jar) to the appropriate folder (in my case is C:\OracleBI\web\javahost\lib)

Finally, when I save my iBot, my twitter status is updated with the text from the Answers view:





2 comments: