One of the optional services in YAWL is the YAWL twitter service. If properly configured, it can be used to update the statuses of user and inform them of available work items for example. But getting it to work can be tricky, as the current version on sourceforge is not working, because Twitter updated their API. For this reason, there is an .war file attached to this article, that includes a working version of the Twitter service. It was originally written by Michael Adams, I only added a newer version of the twitter4j library and changed one line of code from:
Twitter twitter = new TwitterFactory().getInstance();
Twitter twitter = new TwitterFactory().getSingleton();
With that out of the way, now how to make it run with your own twitter account.
Deploying and configurating the twitter service
To deploy the Twitter service on your YAWL installation, simply copy the attached .war file to your YAWL installation folder into the subfolder "engine\apache-tomcat-6.0.18\webapps". After you start the YAWL engine, the tomcat webserver will automatically deploy the Twitter service from that file. The .war file is currently configured for this twitter account.
Now, that the service is properly deployed, you can register it with the YAWL resource service. Log in as an admin and go to ther "Services" tab. There, add a new service with the following parameters:
- Name: twitterService
- Password: yTwitter
- URI: http://localhost:8080/twitterService/ib
- Description: YAWL Twitter service
You can now select the Twitter service in the YAWL Editor and update your status via workflow.
The attached workflow will ask for an update message as input and then update the status of the configured account accordingly.
How to make the twitter service run with your own twitter account, will be explained in the next section.
Setting up the twitter service with another account
First, you will need to add the YAWL service to the allowed applications of your twitter account. To do that, you have to go through the authorization process. Attached to this tutorial, you will also find a jar file, which is the easiest way of obtaining the necessary keys. You can execute the jar file by using the console with the command "java -jar twittering.jar". Inside that jar file is a class "twittering", which is based on the code of the twitter4j examples here. This class will be executed by the command above and when run, it will show a link, that will prompt you to log in to your twitter user and authorize the YAWL app:
After that, a number is shown, and you will need to insert that number in the console to proceed:
If everything is done correctly, you will receive two keys. These keys need to be saved in the twitter4j.properties file of the twitter service, so YAWL can connect to your account. Open the "twitter4j.properties" file in the directory "[YAWL install dirextory]\engine\apache-tomcat-6.0.18\webapps\twitterService\WEB-INF\classes", which should look like this:
Change the values of the keys "oauth.accessToken" and "oauth.accessTokenSecret" with the values you got from executing the twittering.jar file, to make the twitter service work with your account. A restart of YAWL will be necessary to make the changes take effect. The twitter service should now use your account. Thats it!
(Notice: This tutorial is based on YAWL version 2.3.x)