我正在使用 OmniAuth LinkedIn 来验证和存储用户信息。这是我 YAML::dump(response.env['omniauth.auth'].extra.raw_info) 时显示的输出
我的问题:我如何解析这个响应来存储用户的工作经验(列出的几家公司)和用户的教育?
--- !ruby/hash:OmniAuth::AuthHash
educations: !ruby/hash:OmniAuth::AuthHash
_total: 1
values:
- !ruby/hash:OmniAuth::AuthHash
degree: ! '"BS"'
endDate: !ruby/hash:OmniAuth::AuthHash
year: 2014
fieldOfStudy: Information Technology
id: 154175914
schoolName: Florida State University
startDate: !ruby/hash:OmniAuth::AuthHash
year: 2012
emailAddress: mci12@my.fsu.edu
firstName: Michael
headline: Co founder/CTO at Prept.co
id: 9rFcoUgX7u
industry: Information Technology and Services
lastName: Iglesias
location: !ruby/hash:OmniAuth::AuthHash
country: !ruby/hash:OmniAuth::AuthHash
code: us
name: Miami/Fort Lauderdale Area
pictureUrl: http://m.c.lnkd.licdn.com/mpr/mprx/0_eyd5KS_5QNRWff1-HxoVKfQQX-yWSdi-EgjVKaLVRAeMtSqtXsJWOmlqospnaaGOWxIUxWULYrkb
positions: !ruby/hash:OmniAuth::AuthHash
_total: 4
values:
- !ruby/hash:OmniAuth::AuthHash
company: !ruby/hash:OmniAuth::AuthHash
industry: Information Technology and Services
name: InterviewChamp.co
id: 409892806
isCurrent: true
startDate: !ruby/hash:OmniAuth::AuthHash
month: 4
year: 2013
summary: Online marketplace where job seekers can connect with industry professionals
in their desired fields for online video conferencing practice interviews. Job
seekers are able to practice case, behavioral, and technical interviews to help
them prepare and excel at real interviews.
title: Founder/CTO
- !ruby/hash:OmniAuth::AuthHash
company: !ruby/hash:OmniAuth::AuthHash
industry: Information Technology and Services
name: Open Momento Web Development
id: 385398346
isCurrent: true
startDate: !ruby/hash:OmniAuth::AuthHash
month: 5
year: 2012
title: Software Engineer
- !ruby/hash:OmniAuth::AuthHash
company: !ruby/hash:OmniAuth::AuthHash
industry: Information Technology and Services
name: LetUsDorm.com
id: 385404241
isCurrent: true
startDate: !ruby/hash:OmniAuth::AuthHash
month: 1
year: 2012
title: Founder/CEO
- !ruby/hash:OmniAuth::AuthHash
company: !ruby/hash:OmniAuth::AuthHash
id: 2780
industry: Information Technology and Services
name: Amadeus
size: 10,001+ employees
type: Public Company
endDate: !ruby/hash:OmniAuth::AuthHash
month: 5
year: 2012
id: 385401346
isCurrent: false
startDate: !ruby/hash:OmniAuth::AuthHash
month: 5
year: 2011
title: IT Intern
publicProfileUrl: http://www.linkedin.com/in/iglesiasm
这就是我在基于 sinatra 的 app.rb 文件中的内容...
%w(get post).each do |method|
send(method, "/auth/:provider/callback") do
response = (request.env['omniauth.auth']).extra.raw_info
"<pre>" + YAML::dump(response) + "</pre>" + "<br /><br />"
end
end