Friday, March 30, 2007

Twitter posting bot implementation

This is a fast-and-dirty hack to enable posting to twitter. It uses Smack, the java library OpenFire (formerly WildFire) and Spark are built upon, and I used the same IDE (IntelliJ IDEA) which is used by Jive Software to implement their (wonderfully clean-coded) software.

Basic "disadvantages":

  • No bothering with config files (educational purposes) => account/password, admin hardcoded

  • Also, since educational purposes - public domain! (you'd modify an existing source to learn jabber anyway)

  • Uses apache's java HTTP client library - a simple auth to twitter and a POST

  • User binds twitter account by sending a register <twitterusername> <twitterpassword> message to the bot.
  • Doesn't save its state (bot stops => twitter account data lost)- could implement with Serializable markerinterface

  • Doesn't use session-handling: logs into twitter every time; normally, twitter api would need to remember session cookies for each user/pass and trying to simply post the status variable, and if fails (with errorcode 403 presumably), relogin and store session cookies again

  • No multithreading - if twitter is slow, the bot stops responding while doing HTTP query. Normally, at least two threads (one for the twitter api and one for the XMPP connection) should be used.

  • No selective presence/multiple resources/etc - load balancing could be done with bots with same accounts but different resources and probably selective presence/invisibility



You can download java sourcecode here.

The needed libraries - which aren't in public domain(!) - are boundled too.

14 comments:

Anonymous said...

Why not just send a message to twitter's own xmpp bot twitter@twitter.com?

Aadaam said...

because it wasn't available then.. remember "for educational purposes" :)

Hamzah Khan said...

Hi!

I'd just like to say thanks for your post.

I'm working on a small jabber bot for various things smacks aswell and I couldn't find any "full" working example of a bot made using smacks.

Your twitter bot has helped a lot.

Thanks!

Unknown said...

Baltimore Ravens
Buffalo Bills jerseys
Buffalo Bills apparel
Buffalo Bills shirts
jordan basketball shoes
jordan shoes sale
air jordan shoes sale
michael jordan shoes sale
micheal jordan shoes
Manolo blahnik shoes
Christian Louboutin Shoes Sale
Jimmy Choo shoes
Chanel Shoes
RL Solid Polo Shirts Men's
RL Striped Polo Shirts Men's

Anonymous said...

lv owners, please listen up. I am spotting a lot of louis vuitton out there that are being misused and mishandled. These precious Louis vuitton bags should be handled like newborn babies. With a gentle touch and lots of love. louis vuitton handbags are some of the most luxurious of all handbags. You have to appreciate the hard work and craftsmanship put into each Louis item.

fantu❤ said...

The most popular replica handbags in the market are high replica handbags without doubt.


aaa replica handbags are associated with high quality, beautiful styles and elegant temperaments.

Best replica handbags gain popularity no matter in the markets or online. Still replicas, but there are difference.

But not only Louis Vuitton, but also Chanel and Hermes are the most popular brands that designer replica bag comes out.

123 said...

http://www.submitwww.com/user/view/history/login/hoganscarpes222
http://www.submitwww.com/user/view/history/login/lidadaidaihua111
http://www.submitwww.com/user/view/history/login/viagra111
http://www.submitwww.com/user/view/voted/login/breitling123
http://www.submitwww.com/user/view/voted/login/Chanel123
http://www.submitwww.com/user/view/voted/login/choosemy123
http://www.submitwww.com/user/view/voted/login/coach123
http://www.submitwww.com/user/view/voted/login/dvd123
http://www.submitwww.com/user/view/voted/login/eshopping123

Anonymous said...

I just read the "disadvantages" and they are pretty cool, I tend to post a lot on twitter and I was looking for something like this. I was working on a Sildenafil version for twitter, but this is better!

Anonymous said...

wetwtwtwtwtwqtwe

Anonymous said...

dsgregretret

coach said...

Coach Shoulder BagsThe Reagan Nationalcoach outlet online incident, around Coach Poppy Bagsmidnight Tuesdaycoach outlet store night, hasGucci Shoes sent administrationCoach Tote Bags officialsCoach Hobo Bags scramblinggucci sale to assure thegucci outlet public that safety isn’t being compromisedasics shoes. Transportation Secretaryonitsuka tiger mexico 66 Ray LaHood has orderedasics outlet an examination of gucci handbags salecontroller staffing at airports across the nation, and he directed that two controllers staff the midnight shift in Washington from now on.

Allen Smith said...

Excellent post from skilled also it would in all probability be a beautiful know-learn how to us and thank you numerous for posting this useful data with us all.
acid reflux remedies

Karlsson said...

okay well, I think it has advantages and disadvantages too, that's simple it is similar when I go to the pharmacy drugstore and I can get different advantages and disadvantages about the medicines they offer.

Unknown said...

Glad to visit your site. An awesome blog. Nice Information It's really very informative that I wanted ever, thanks for this. Jual Peninggi Badan Alami Bali Ratih Obat Jerawat Obat Asam Urat AlamiKapsul Mengkudu Obat Pelangsing Badan HerbalMadu Hitam Pahit Masker Wajah Alami