In my User
model, I have the following code:
def twitter_client
OAuth::AccessToken.new(twitter_oauth, self.access_token_key, self.access_token_secret)
end
def twitter_oauth
OAuth::Consumer.new(Twitter::Login.consumer_key, Twitter::Login.secret, :site => Twitter::Login.site)
end
This way I can call User#twitter_client like so:
current_user.t开发者_Go百科witter_client.post('/statuses/update.xml', {'status' => 'foooo', 'Accept' => 'application/xml'})
This works well, and actually does update the status, and returns the following:
#<Net::HTTPOK 200 OK readbody=true>
This really is not a problem for updating statuses. However, when I want to get the latest tweets, all I get is a response code object, without the actual content from the response:
current_user.twitter_client.get('/statuses/user_timeline.xml', {'Accept' => 'application/xml'})
=> #<Net::HTTPOK 200 OK readbody=true>
This returned object is just an instance of Net::HTTPOK
and contains no tweet data.
How do I get the tweet data?
How about...?
res = current_user.twitter_client.get('/statuses/user_timeline.xml', {'Accept' => 'application/xml'})
puts res.body
精彩评论