我会尽量保持简单,我之前的措辞可能有点过于冗长:
这是 Omniauth 哈希示例:https ://github.com/mkdynamic/omniauth-facebook
我可以从中访问和保存一些值,但不能保存其他值。该字段是可写的,所以我知道它只是我的语法(初学者,对不起!)
{
:provider => 'facebook',
:uid => '1234567',
:info => {
:nickname => 'jbloggs',
:email => 'joe@bloggs.com',
:name => 'Joe Bloggs',
:first_name => 'Joe',
:last_name => 'Bloggs',
:image => 'http://graph.facebook.com/1234567/picture?type=square',
:urls => { :Facebook => 'http://www.facebook.com/jbloggs' },
:location => 'Palo Alto, California',
:verified => true
},
:credentials => {
:token => 'ABCDEF...', # OAuth 2.0 access_token, which you may wish to store
:expires_at => 1321747205, # when the access token expires (it always will)
:expires => true # this will always be true
},
:extra => {
:raw_info => {
:id => '1234567',
:name => 'Joe Bloggs',
:first_name => 'Joe',
:last_name => 'Bloggs',
:link => 'http://www.facebook.com/jbloggs',
:username => 'jbloggs',
:location => { :id => '123456789', :name => 'Palo Alto, California' },
:gender => 'male',
:email => 'joe@bloggs.com',
:timezone => -8,
:locale => 'en_US',
:verified => true,
:updated_time => '2011-11-11T06:21:03+0000'
}
}
}
我可以这样做来获取性别并保存它。
location:auth.extra.raw_info["gender"]
显然,虽然我不想将性别保存到位置。我想得到“帕洛阿尔托”并保存它。但这不起作用。
location.auth.extra.raw_info["location"]["name"]
我究竟做错了什么?当我在控制台中尝试时,我能够获得价值。