Capistrano Twitter task, take 2 2
In my original post, I explained how I used the twitter4r gem to post when we deployed an app with capistrano. Chris Matthieu posted a comment about how to do it without the twitter4r gem. I actually like this better, especially after we started having trouble with the twitter4t gem. So, here’s his version that I adapted slightly:
desc 'posts to twitter that an application has been deployed to a web server'
task :send_tweet do
require 'open-uri'
require 'net/http'
url = URI.parse('http://twitter.com/statuses/update.xml')
req = Net::HTTP::Post.new(url.path)
req.basic_auth 'your_username' + ":" + 'your_password', ''
req.set_form_data({'status' => "Deployed #{application} to #{rails_env}"})
res = Net::HTTP.new(url.host, url.port).start {|http| http.request(req) }
endThanks, Chris!
Comments
-
What kind of Twitter4R problem? I have never had an issue with Twitter4R gem except the 70 reqs/min limit that has nothing to do with Twitter4R and you will still experience the same issue with the above task.
-
Hey, I put together a small Twitter script in Ruby that you could easily tie into a Cap task. It allows you to not only update, but also direct message and view sent direct messages (as those were the functions I needed). It wouldn't be tough to add more. The script is here: http://configurati.com/pages/a-twitter-script
