oshyn: OpenText RedDot LiveServer integration with Twitter
written by oshyn Team, 11. September 2011
How can businesses integrate Twitter with their websites to efficiently share their updates with followers and other “tweeple” they want to engage? Twitter can open dialogue between companies and clients either in a B2C or B2B, allowing all parties to share their concerns, likes, wants, information, announcements, best practices – the list is endless. However, the nature of Twitter makes doing this on Twitter.com a tedious and costly exercise for companies. So I decided to build a solution using OpentText RedDot LiveServer.
The integration of Twitter with a OpentText RedDot LiveServer will enable a company that uses Twitter to send Tweets whenever company’s website is update. For example, when a new article is published on the website, a message cans automatically Tweet-ed. Instead of logging into another place like TweetLater, OpentText RedDot LiveServer can be integrated with a Twitter API for automatically tweet.
To do this integration we need to create a Java Method that is in charge of tweeting the desired messages using the Java Twitter API “Twitter4j” located in http://twitter4j.org/en/index.html. The important part is that the published page should contain a content attribute with the desired information that we want to tweet. We can use the architecture described in the blog “How to Integrate LiveServer and Drools” to apply business rules that need to be met when a page is created or by simply using LiveServer events and Java Methods.
The steps are:
- Download the file TwitterIntegrator.jar
- Modify the properties file located inside the mentioned jar. Here you need to set up the desired Twitter account to use. The content attribute of the pages has the information that you want to tweet and the file name that is going to contain log information. This file looks like this:
- #Twitter Application Properties
- The next step is to download the Twitter API located in http://twitter4j.org/en/index.html and to put it with the TwitterIntegrator.jar in the folder Live Server Root/WEB-INF/lib.
- Register in LiveServer the Java Method “toTweet” of the class “com.oshyn.twitter.TwitterSender”
Twitter4j is a Twitter API that integrates applications with the Twitter Service, in order that applications can send messages up to 140 characters. This API permits you to tweet, send direct messages to specific users, search for tweets, follow users, etc. One important characteristic of this API is that its uses twitter web services for the communication and is thread – safe, so you can make method calls concurrently. Following is a short code example of how to tweet using the JAVA API Twitter4j:
Twitter twitter = new Twitter(“user”, “password”);
Status status = twitter.updateStatus(message);
Integrating additional functionality with LiveServer can be done using the architecture explained in the blog Integration between OpenText RedDot LiveServer and Drools or you can implement integrations directly registering Java Methods in LiveServer. I’ll be writing more about LiveServer soon!
Source: OpenText RedDot LiveServer Integration with Twitter
© copyright 2011 by oshyn