Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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
Add Comment
Please, Sign In to add comment