Integrating Pebble Blog with Tweeter
A couple of weeks ago we had a "Join Twitter" storm at Xebia. After the Linked-in, Plaxo, Hyves, Facebook and probably a dozen of other social network storms I initially decided to pass on Twitter. But then by colleague JCP Colleague & Friend Andreas posted an entry about twitter and that convinced me to join. Why? This sentence basically did it: "Twitter can promote your blog by sending out new blog posts." This could help to draw some extra traffic to the blog...
I immediately checked if there already was a plug-in for Pebble (the webapp that hosts this blog) that would allow me link my blog to Twitter. SinceI could not find something quickly and the functionality would be really simple I decided to create the plug-in for Pebble myself. So If all goes well each blog entry that I'll post or update to my blog will result in a Twitter update. And this blog entry should be the first proof of that ;-)
In case you're interested in including this in your own Pebble blog:
I immediately checked if there already was a plug-in for Pebble (the webapp that hosts this blog) that would allow me link my blog to Twitter. SinceI could not find something quickly and the functionality would be really simple I decided to create the plug-in for Pebble myself. So If all goes well each blog entry that I'll post or update to my blog will result in a Twitter update. And this blog entry should be the first proof of that ;-)
In case you're interested in including this in your own Pebble blog:
- Download the TwitterTweeter.java source and compile it against your Pebble code
- Add the resulting class (jar) to the classpath of your servlet container
- Restart the servlet container.
- Add net.vermaas.TwitterTweeter in the Blog Plug-in configuration as Blog Entry Listener and Comment Listener.
- Add the following three properties in the Blog Plug-in configuration as Properties
TwitterTweeter.password=[your Twitter password]
TwitterTweeter.twitterUrl=https://twitter.com/statuses/update.xml
TwitterTweeter.userName=[your twitter user name]
** UPDATE **:
Sending out tweets on each publish, update, delete and each and every comment being posted proved to be a bit of an overkill. Therefore 2 additional properties are added:
TwitterTweeter.blog.entry.tweets=[Determines on what blog entry actions to sent a tweet]
TwitterTweeter.comment.tweets=[Determines on what comment actions to sent a tweet]
(See comments in source for valid values for these last two settings)
** EO UPDATE **
- Restart your servlet container
Re: Integrating Pebble Blog with Tweeter
I didn't know about http://www.twitterfeed.com/ yet, but that is also a nice solution. Advantage would be that you can use this solution with any blog that publishes an RSS/Atom feed... which is basically any blog. So you're not limited to a Pebble blog on which you can install new plug-ins.
Disadvantages... well, it does not immediately publish to Twitter after you post to the blog. It only polls your feed periodically and this plug-in immediately published to Twitter once you post a blog entry or when a comment is posted. And you don't have the fun of building you own plug-in of course....
On the authentication side, my solution and twitterfeed have the same limitations, see the "Authentication" section on of the Twitter API.
However, just for fun I changed the Twitter URL from http to https and it looks as if this works... If this comments shows up on my Twitter I'll update the blog entry and remove the note on username/password traveling in plain text over the Net... so that's how you can see that it works ;-
Disadvantages... well, it does not immediately publish to Twitter after you post to the blog. It only polls your feed periodically and this plug-in immediately published to Twitter once you post a blog entry or when a comment is posted. And you don't have the fun of building you own plug-in of course....
On the authentication side, my solution and twitterfeed have the same limitations, see the "Authentication" section on of the Twitter API.
However, just for fun I changed the Twitter URL from http to https and it looks as if this works... If this comments shows up on my Twitter I'll update the blog entry and remove the note on username/password traveling in plain text over the Net... so that's how you can see that it works ;-
Re: Integrating Pebble Blog with Tweeter
Hello Gero, i added twittertweeter.java to the pebble project i have in eclipse. This is easier with the build.xml since allthe libraries and other goodies are already there. Also, since your packaging started with *net* i only had to add the codeunder: src/net/java and add a <jar> element to the build.xml build target to get the twittertweeter.jar.. BTW: your source-file package references net.vermaas but your instructions below use the package designation net.java so I changed to package name to reflect the proper package name according to the instructions below. i made two very small changes in the build.xml to get the needed twittertweeter.jar output along side the pebble.jar using the build.xml build target. I followed the instructions at: http://gerodt.homeip.net/blog/gero/2008/04/06/1207505880000.html verbatim but pebble.war failed to deploy with the twittertweeter.jar in the lib directory. I removed the twittertweeter.jar and pebble.war redeployed no problemo. Please find the server.log exceptions and the pebble messages are removal of twittertweeter.jar included below. TIA and please advise, David.
2008-04-21 16:05:02,037 INFO [STDOUT] 2008-04-21 16:05:02,034 [main] WARN org.acegisecurity.intercept.AbstractSecurityInterceptor
- Could not validate configuration attributes
as the MethodDefinitionSource did not return a ConfigAttributeDefinition Iterator
2008-04-21 16:05:02,117 INFO [STDOUT] 2008-04-21 16:05:02,116 [main] INFO net.sourceforge.pebble.web.listener.PebbleContextListener
- Starting Pebble
2008-04-21 16:05:02,622 INFO [STDOUT] 2008-04-21 16:05:02,617 [main] ERROR org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/pebble]
- Exception sending context
initialized event to listener instance of class net.sourceforge.pebble.web.listener.PebbleContextListener
java.lang.NoClassDefFoundError: net/sourceforge/pebble/api/event/blogentry/BlogEntryListener
Re: Integrating Pebble Blog with Tweeter
David,
Thanks for point to the typo in the package name, it is now corrected in the blog post.
I'm not sure what is causing this problem. They way I'm deploying the generated jar is by just dropping in the webapps//pebble-2.1/WEB-INF/lib directory of Tomcat (v. 5.5.20) and that works OK.
I checked my catalina.out log file and noticed that I also have the Acegi warning and that is probably caused by the fact that the tweet(String msg) method is setting the Authenticator. It does work however, but probably could be improved by using Acegi just as Pebble does.
The PebbleContextListener error is weird because the TwitterTweeter class is not using the PebbleContextListener interface at all. It did in an old version, but I though I never put that version on the web. Could you try again using the latest version? The link in the blog post points to the latest Java source.
Furthermore I'm using Pebble 2.1... could that be a cause?
Gero
Thanks for point to the typo in the package name, it is now corrected in the blog post.
I'm not sure what is causing this problem. They way I'm deploying the generated jar is by just dropping in the webapps//pebble-2.1/WEB-INF/lib directory of Tomcat (v. 5.5.20) and that works OK.
I checked my catalina.out log file and noticed that I also have the Acegi warning and that is probably caused by the fact that the tweet(String msg) method is setting the Authenticator. It does work however, but probably could be improved by using Acegi just as Pebble does.
The PebbleContextListener error is weird because the TwitterTweeter class is not using the PebbleContextListener interface at all. It did in an old version, but I though I never put that version on the web. Could you try again using the latest version? The link in the blog post points to the latest Java source.
Furthermore I'm using Pebble 2.1... could that be a cause?
Gero
Re: Integrating Pebble Blog with Tweeter
Hi Gero
You seem to know Pebble pretty well and so I am asking you a question if you don't mind.
I want to include an rss feed in my blog, that is, I want to show a feed formatted as html in the content area as a separate page.
I have an example of rss reading jsp but I cannot see how I can get it to show in the content area.
Any ideas? Any clues would be appreciated.
I'm on version 1.9 as my host has not upgraded to Java 5 yet...
Thanks in advance.
Regards
Lyndon