2

我需要如何从以下输出中获取单个值:

@auth_hash = request.env['omniauth.auth']
 <p><%= @auth_hash.inspect %></p>// i got following out from this line of code '

例如,我需要名称、帐户和用户,如何获取?

#<OmniAuth::AuthHash
 credentials=#<Hashie::Mash expires=true expires_at=12233 token="wwewewewqeqweqweqwewqewqewqewqewewqewqewewqewqewqewqeqwewqewqewqqxcfdvfgfghfhgfhgfhgfhgghfhggfhgfhgfhgfhgh">
 extra=#<Hashie::Mash raw_info=#<Hashie::Mash
 education=[#<Hashie::Mash school=#<Hashie::Mash id="131103480269939"
  name="zxsd sdsr"> type="High School">, #<Hashie::Mash school=
  #<Hashie::Mash id="107936305917315" name="GHSS BANGRA yyyyy">
  type="High School" year=#<Hashie::Mash id="113125125403208" name="2004">>,
  #<Hashie::Mash school=#<Hashie::Mash id="198825526799921" name="vhse kunjathur">
  type="High School" year=#<Hashie::Mash id="113125125403208" name="2004">>]
 email="xxxxxx@yahoo.co.in" first_name="zxxxxxxxx" gender="male"
 hometown=#<Hashie::Mash id="107013659338585" name="yyyyyyy, Kerala, India">
 id="502830644" last_name="xxxxx" link="http://www.facebook.com/xxxxxx"
 locale="en_US" location=#<Hashie::Mash id="106216379410251" name="Mangalore">
 name="xxxxxxxxxxxx" timezone=5.5 updated_time="2012-04-01T05:08:36+0000"
 username="xxxxxx" verified=true>> info=#<OmniAuth::AuthHash::InfoHash
 email="xxxxxx@yahoo.co.in" first_name="xxxxxxx"
 image="http://graph.facebook.com/502830644/picture?type=square"
 last_name="xxxxxxx" location="Mangalore" name="xxxxxxxx xxxxxxx"
 nickname="xxxxxx" urls=#<Hashie::Mash Facebook="http://www.facebook.com/xxxxx">
 verified=true> provider="facebook" uid="566767666">
4

1 回答 1

1

你应该检查https://github.com/mkdynamic/omniauth-facebook#auth-hash

request.env['omniauth.auth'][:info][:name]
于 2012-09-01T05:48:37.153 回答