Skip to content

Instantly share code, notes, and snippets.

@atog
Created October 21, 2009 16:49
Show Gist options
  • Save atog/215254 to your computer and use it in GitHub Desktop.
Save atog/215254 to your computer and use it in GitHub Desktop.
require "net/http"
def twit(username, password, status, timeout=10)
response = Net::HTTP.start('twitter.com', 80) do |http|
req = Net::HTTP::Post.new("/statuses/update.xml")
req.set_form_data({'status'=> status})
req.basic_auth(username, password)
http.read_timeout = timeout
http.request(req)
end
unless (response.message == 'OK' || response.message == "Unauthorized" || response.message == "Not Found")
raise StandardError.new(response.message)
end
puts response.body
end
puts "Enter username:"
username = gets.gsub("\n","")
puts "Enter password:"
password = gets.gsub("\n","")
puts "Enter tweet:"
tweet = gets
# username = ""
# password = ""
twit username, password, tweet
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment