Linkedin Gem for Rails application
This is an example to use Linkedin Gem for using linkedin api inside your rails application
If you wanted to replace these things APP_CONFIG['api_key'] with your api keys you can also do that.
These are the things that are fetched by the linkedin gem using the api
first-name last-name headline positions educations skills
You can use @profile to fetch the values and use them according to your requirement.
If you wanted to replace these things APP_CONFIG['api_key'] with your api keys you can also do that.
These are the things that are fetched by the linkedin gem using the api
first-name last-name headline positions educations skills
You can use @profile to fetch the values and use them according to your requirement.
class UserController < ApplicationController
def login
client = LinkedIn::Client.new(APP_CONFIG['api_key'], APP_CONFIG['secret_key'])
request_token = client.request_token(:oauth_callback => "http://#{request.host_with_port}/user/authenticate_login")
session[:rtoken] = request_token.token
session[:rsecret] = request_token.secret
redirect_to client.request_token.authorize_url
end
def profile
end
def authenticate_login
client = LinkedIn::Client.new(APP_CONFIG['api_key'], APP_CONFIG['secret_key'])
if session[:atoken].nil?
pin = params[:oauth_verifier]
atoken, asecret = client.authorize_from_request(session[:rtoken], session[:rsecret], pin)
session[:atoken] = atoken
session[:asecret] = asecret
else
client.authorize_from_access(session[:atoken], session[:asecret])
end
@profile = client.profile(:fields => %w(first-name last-name headline positions educations skills))
@connections = client.connections
render :action => :profile
end
end
Comments
Post a Comment