这个问题与这里的同一个问题有关,但我仍然面临同样的问题,linkedin 仅提供当前位置信息,我如何使用 Rails 中的linkedin gem获取过去的职位和教育详细信息,我的linkedin 控制器已经如下图,需要您的帮助。
require 'linkedin'
class LinkedinUserController < ApplicationController
def init_client
key = "XXXXXX"
secret = "XXXXXX"
linkedin_configuration = { :site => 'https://api.linkedin.com',
:authorize_path => '/uas/oauth/authenticate',
:request_token_path =>'/uas/oauth/requestToken?scope=r_basicprofile+r_fullprofile+r_emailaddress+r_network+r_contactinfo',
:access_token_path => '/uas/oauth/accessToken' }
@linkedin_client = LinkedIn::Client.new(key, secret,linkedin_configuration)
end
def auth
init_client
request_token = @linkedin_client.request_token(:oauth_callback => "http://#{request.host_with_port}/linkedin/callback")
session[:rtoken] = request_token.token
session[:rsecret] = request_token.secret
redirect_to @linkedin_client.request_token.authorize_url
end
def callback
init_client
if session[:atoken].nil?
pin = params[:oauth_verifier]
atoken, asecret = @linkedin_client.authorize_from_request(session[:rtoken], session[:rsecret], pin)
session[:atoken] = atoken
session[:asecret] = asecret
else
@linkedin_client.authorize_from_access(session[:atoken], session[:asecret])
end
c = @linkedin_client
c.profile(:fields=>["first_name","last_name","headline","positions","educations"])
end
end