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中试过这个,并且出现了同样的错误。
试试'的access_token [:USER_ID]'或'ACCESS_TOKEN [PARAMS] [:USER_ID]' –
都导致内部服务器错误 – Imnotanerd
怎么样'access_token.params [:USER_ID]'? –