0

我正在使用 gem twitter_oauth。我放入令牌,然后得到我的access_token. 现在我想访问这个哈希中的一些信息,但由于某种原因它不会让我这样做。我能做的最好的就是检查它:

access_token.inspect #=>
#<OAuth::AccessToken:0x72ca83b2 @params={:oauth_token=>"token (filtered of course)", "oauth_token"=>"token", :oauth_token_secret=>"secret", "oauth_token_secret"=>"secret", :user_id=>"id", "user_id"=>"id", :screen_name=>"Imnotanerd", "screen_name"=>"Imnotanerd"}, @response=#<Net::HTTPOK 200 OK readbody=true>, @consumer=#<OAuth::Consumer:0x6bb7645d @http_method=:post, @options={:signature_method=>"HMAC-SHA1", :request_token_path=>"/oauth/request_token", :authorize_path=>"/oauth/authenticate", :access_token_path=>"/oauth/access_token", :proxy=>nil, :scheme=>:header, :http_method=>:post, :oauth_version=>"1.0", :site=>"http://api.twitter.com", :request_endpoint=>nil}, @secret="secret", @http=#<Net::HTTP api.twitter.com:80 open=false>, @uri=#<URI::HTTP:0x384bc24e URL:http://api.twitter.com>, @key="key">, @token="token", @secret="secret">

我试图访问这样的值:

access_token[params]["user_id"] #gave up on this due to me reasoning that it's confusing params with the routing variable, params
access_token["params"]["user_id"]
access_token["consumer"]["secret"]

所有这些都导致了内部服务器错误。报告错误时没有提供其他信息。

我正在使用 JRuby 1.7 RC2 和最新的 Trinidad Web 服务器。我也在 WEBrick 中尝试过这个,并且出现了同样的错误。

4

1 回答 1

0

由于已经几个月了,我只是添加了上面@ionut-hulub 回答的官方答案,所以这个已经回答的问题不再出现而没有答案。

access_token.params[:user_id]
于 2013-05-14T03:24:21.000 回答