开发者

Only getting response codes, but not actual response, from OAuth::AccessToken

开发者 https://www.devze.com 2023-03-06 11:00 出处:网络
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)

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
0

精彩评论

暂无评论...
验证码 换一张
取 消