Guest User

Untitled

a guest
Mar 14th, 2018
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. require "net/http"
  2.  
  3. def twit(username, password, status, timeout=10)
  4. response = Net::HTTP.start('twitter.com', 80) do |http|
  5. req = Net::HTTP::Post.new("/statuses/update.xml")
  6. req.set_form_data({'status'=> status})
  7. req.basic_auth(username, password)
  8. http.read_timeout = timeout
  9. http.request(req)
  10. end
  11. unless (response.message == 'OK' || response.message == "Unauthorized" || response.message == "Not Found")
  12. raise StandardError.new(response.message)
  13. end
  14. puts response.body
  15. end
  16.  
  17. puts "Enter username:"
  18. username = gets.gsub("\n","")
  19. puts "Enter password:"
  20. password = gets.gsub("\n","")
  21. puts "Enter tweet:"
  22. tweet = gets
  23.  
  24. # username = ""
  25. # password = ""
  26.  
  27. twit username, password, tweet
Add Comment
Please, Sign In to add comment