2

我在 Rails 中使用 omniauth-linkedin gem 并尝试从“r_fullprofile”和“r_network”获取数据。

在omniauth.rb 中:

  provider :linkedin, 'consumer_key', 'consumer_secret', 
       :scope => 'r_fullprofile r_emailaddress r_network', 
       :fields => ["id", "email-address", "first-name", "last-name", 
                   "headline", "industry", "picture-url", "public-profile-url", 
                   "location", "connections", "skills", "date-of-birth", "phone-numbers",        
                   "educations", "three-current-positions" ]

在控制器中:

render :text => request.env["omniauth.auth"].to_yaml

结果输出似乎只有“r_basicprofile”的数据。我怎样才能获得解析所需数据的其余部分(例如“连接”、“技能”、“教育”)?

4

2 回答 2

0

我在使用 Devise 的 Omniauth 时遇到了同样的问题。

我必须进行更改以将 :fields => [...] 放入花括号中。

在你的情况下:

  provider :linkedin, 'consumer_key', 'consumer_secret', 
       {:scope => 'r_fullprofile r_emailaddress r_network', 
       :fields => ["id", "email-address", "first-name", "last-name", 
                   "headline", "industry", "picture-url", "public-profile-url", 
                   "location", "connections", "skills", "date-of-birth", "phone-numbers",        
                   "educations", "three-current-positions" ]}

希望这可以帮助。

于 2013-08-14T08:06:48.540 回答
0

不知道这是否会对您有所帮助,但现在有些字段有不同的名称。我把它放在我的 devise.rb 上,它可以工作:

config.omniauth :linkedin, ENV['OAUTH_LINKEDIN_ID'], ENV['OAUTH_LINKEDIN_SECRET'],
fields: %w(id email-address first-name last-name headline industry picture-url public-profile-url location num-connections), image_size: {height: 1600}

connections现在是num-connections,请参阅Linkedin 文档

于 2015-11-24T09:46:57.650 回答