仅从 OAuth::AccessToken 获取响应代码,但未获取实际响应
在我的 User
模型中,我有以下代码:
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
这样我就可以像这样调用 User#twitter_client:
current_user.twitter_client.post('/statuses/update.xml', {'status' => 'foooo', 'Accept' => 'application/xml'})
这效果很好,并且实际上确实更新了状态,并返回以下内容:
#<Net::HTTPOK 200 OK readbody=true>
这确实不是更新状态的问题。但是,当我想获取最新的推文时,我得到的只是一个响应代码对象,而没有响应中的实际内容:
current_user.twitter_client.get('/statuses/user_timeline.xml', {'Accept' => 'application/xml'})
=> #<Net::HTTPOK 200 OK readbody=true>
此返回的对象只是 Net::HTTPOK
的实例,并且不包含推文数据。
如何获取推文数据?
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.twitter_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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
怎么样...?
How about...?