[英]How do I get more granular LinkedIn user information using linkedin gem and omniauth?
我想從他們的LinkedIn個人資料(公司名稱,職位等)中獲取用戶的位置信息,但我得到的不僅僅是基本的個人資料信息(身份證,姓名,電子郵件,標題和圖片)。 我猜這只是一種語法,因為我在用戶身份驗證時請求訪問所有字段。
來自user.rb
def self.from_omniauth(auth)
where(auth.slice(:provider, :uid)).first_or_initialize.tap do |user|
user.provider = auth.provider
user.uid = auth.uid
user.name = auth.info.name
user.email = auth.info.email
user.headline = auth.info.headline
**user.company = auth.info.company**
user.avatar = auth.info.image
user.password = SecureRandom.urlsafe_base64(n=6)
user.save!
end
來自devise.rb
config.omniauth :linkedin, "abcdefghijk", "abcdefghijk",
# :scope => 'r_basicprofile r_emailaddress rw_nus r_fullprofile r_contactinfo r_network rw_company_admin',
# :fields =>
:scope => 'r_basicprofile r_emailaddress rw_nus r_fullprofile r_contactinfo r_network rw_company_admin',
: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" ]
我是否需要向devise.rb添加字段,或者我是一個白痴並格式化user.company = auth.info.company
錯誤?
謝謝!
[編輯]好吧,找到了。 devise.rb字段定義錯誤。 (可能已經過時了,我使用了同樣的東西,它是從某處復制的。)
正確的名字現在只是“位置”,而不是“三個當前位置”
之后, auth.extra.info.positions
變得可用(使用這些參數: https : //developer.linkedin.com/docs/fields/positions )
訪問用戶信息ID的格式為:
user.name = auth["info"]["name"]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.