Class: Twitterize::TwitterAPI

Inherits:
Object
  • Object
show all
Defined in:
lib/twitterize.rb

Class Method Summary collapse

Class Method Details

.post(user, password, status) ⇒ Object



118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# File 'lib/twitterize.rb', line 118

def self.post(user, password, status)
  post_args = {
    'status' => status,
    'source' => 'twitterize'
  }

  url = URI.parse('http://twitter.com/statuses/update.xml')
  url.user = user
  url.password = password

  response = Net::HTTP::post_form url, post_args
  puts response.inspect

  case response
  when Net::HTTPSuccess then
    puts "POSTING #{status}"
  when Net::HTTPFound then
    puts "POSTING #{status}"
  else
    raise TwitterException, response
  end
end