I saw a cute demonstration of tweeting from R in a presentation some months ago. The scratch code used by the presenter is here:
http://www.r-bloggers.com/twitter-f
Besides the code you show, there is also a full-blown twitteR package on CRAN you could look at.