TwitterMeThis/Ruby
Funktioniert laut Ruby-Doc. Laut Ruby aber nicht. Und die Verwirrung wird groß sein. --Frei nach das Leben des Brian
#TwitterMeThis - Twitter Update Script. Written by oneup.
#Usage: twitter_this('user','password','here be the message.')
require 'net/http'
require 'uri'
def twitter_this username, password, message
#submit status=message to http://twitter.com/statuses/update.xml
#authentication via http header Authorization Basic username:password
Net::HTTP.start('twitter.com') do |http|
req = Net::HTTP::Post.new('/statuses/update.xml')
req.basic_auth(username, password)
req.set_form_data({'status' => message}, ';')
response = http.request(req)
case response
when Net::HTTPSuccess
return true
when Net::HTTPUnauthorized
print "Wrong username/password. (HTTP 401)\n"
else
print "Something went wrong. (HTTP #{response.code} - #{response.class.to_s})\n"
end
end
return false
end