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.

21 comments:

fanf 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" :)

butlimous said...

Thanks for the nice post!

Free PS3

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!

milf said...

black mold exposureblack mold symptoms of exposurewrought iron garden gatesiron garden gates find them herefine thin hair hairstylessearch hair styles for fine thin hairnight vision binocularsbuy night vision binocularslipitor reactionslipitor allergic reactionsluxury beach resort in the philippines

afordable beach resorts in the philippineshomeopathy for eczema.baby eczema.save big with great mineral makeup bargainsmineral makeup wholesalersprodam iphone Apple prodam iphone prahacect iphone manualmanual for P 168 iphonefero 52 binocularsnight vision Fero 52 binocularsThe best night vision binoculars here

night vision binoculars bargainsfree photo albums computer programsfree software to make photo albumsfree tax formsprintable tax forms for free craftmatic air bedcraftmatic air bed adjustable info hereboyd air bedboyd night air bed lowest pricefind air beds in wisconsinbest air beds in wisconsincloud air beds

best cloud inflatable air bedssealy air beds portableportables air bedsrv luggage racksaluminum made rv luggage racksair bed raisedbest form raised air bedsaircraft support equipmentsbest support equipments for aircraftsbed air informercialsbest informercials bed airmattress sized air beds

bestair bed mattress antique doorknobsantique doorknob identification tipsdvd player troubleshootingtroubleshooting with the dvd playerflat panel television lcd vs plasmaflat panel lcd television versus plasma pic the bestThe causes of economic recessionwhat are the causes of economic recessionadjustable bed air foam The best bed air foam

hoof prints antique equestrian printsantique hoof prints equestrian printsBuy air bedadjustablebuy the best adjustable air bedsair beds canadian storesCanadian stores for air beds

migraine causemigraine treatments floridaflorida headache clinicdrying dessicantair drying dessicantdessicant air dryerpediatric asthmaasthma specialistasthma children specialistcarpet cleaning dallas txcarpet cleaners dallascarpet cleaning dallas

vero beach vacationvero beach vacationsbeach vacation homes veroms beach vacationsms beach vacationms beach condosmaui beach vacationmaui beach vacationsmaui beach clubbeach vacationsyour beach vacationscheap beach vacations

bob hairstylebob haircutsbob layeredpob hairstylebobbedclassic bobCare for Curly HairTips for Curly Haircurly hair12r 22.5 best pricetires truck bustires 12r 22.5

washington new housenew house houstonnew house san antonionew house venturanew houston house houston house tx

rootpp said...

funny jokes

kobe123456 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

longge 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.

太子 said...

If you have been looking for the right BEWITCHED to AVI converter that is powerful as well as customer friendly then you have certainly found one. It is not only easy to use BEWITCHED DVD but extremely convenient to. You will adore the speed at which it can go on to convert and diversify BEWITCHED DVD COLLECTION videos into video formats and at the most satisfactory of quality output possible.


lida can be put to use to reduce the effort that is required for reducing weight. You can easily reduce your body weight with the help of lida daidaihua that are available. There are slimming capsules that are making these products available. You can use the weight loss products with daidaihua for better and faster improvement in body weight. There are a number of ways of checking out the lida slimming that are available. You can take the help of the internet to check slimming capsule that are available.

fantutu 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.

ge 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

Carmina 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!

Young said...

These onitsuka tiger online shop are buy asics tigers online awesome, tiger asics shoes but huge! I cheap onitsuka tiger had to asics tiger australia return twice cheap onitsuka tiger shoes because they onitsuka tiger zodiac were so big asics tiger I normally onitsuka tiger australia wear a 7.5 but ended up fitting asics onitsuka tiger mexico nicely into a tiger mexico 66. Other than that, onitsuka tiger shoes australia they look spiffy, seem onitsuka tiger mexico 66 black well made tiger mini cooper only had asics onitsuka so far, and they tiger shoes australia are still holding buy onitsuka tiger shoes online together mexico 66 perfectly, onitsuka tiger yellow black as they should be), and onitsuka tiger tokyo they came onitsuka tiger ultimate 81 with two asics onitsuka tiger trainers colors of laces asics kinsei. I onitsuka tiger mexico 66 yellow black would certainly tiger shoes onitsuka buy other onitsuka tiger sale colors of discount asics running shoes that I know onitsuka tiger mexico 66 my correct onitsuka tiger black white this brand buy onitsuka tiger shoes is a good asics international shipping best online onitsuka tiger online store

Minor said...

wetwtwtwtwtwqtwe

sunrise10 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.

Ranganath said...

Hi, Some one from facebook refereed your link i have book marked it nice blogs you write see Free  how to grow twitter followers here

Emma jacob said...

I adore your blog because I never know about Handwriting expert what I am getting into when I open a new post. You do a great Job, regarding Handwriting analyst Quality content always have a dash of personal life and my next task I collect some more info about Handwriting analysis .Any how Keep up the great blogging and! Good luck with your new project--I hope everything works out for you! Happy 2011 :).

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.

Khaliqah Rahma 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