Imnotanerd
Imnotanerd

Reputation: 1167

Getting a value out of a hash

I'm using the gem twitter_oauth. I put in the tokens, and I get my access_token. Now I want to access some information in this hash, but it won't let me for some reason. The best I can do is inspect it:

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">

I tried to access the values like so:

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"]

And all of these resulted in an Internal Server Error. No other information was given when the error was reported.

I'm using JRuby 1.7 RC2, and the latest Trinidad web server. I have also tried this in WEBrick too, and the same error appears.

Upvotes: 0

Views: 121

Answers (1)

Rob.Kachmar
Rob.Kachmar

Reputation: 2188

Since it's been several months, I'm just adding the official answer that @ionut-hulub answered above so this already answered question stops showing up with no answer.

access_token.params[:user_id]

Upvotes: 0

Related Questions