get linkedin friends list in ruby on rails

Hi i have found solution to how to get linked in friends list using token and secret.
First of fall you should must authenticated with linkedin.
Put this code where you want to fetch linked in friends.

 client = linked_in_client(current_user.authentication)

@profile = client.profile
 @my_connections = client.connections.all


def linked_in_client(detail)
    LinkedIn.configure do |config|
      config.token = "75keyc3e2w7pyc"
      config.secret = "97c1znGyaEJrM8bY"
      config.default_profile_fields = ['id', "first-name", "last-name"]
    end
    linked_in = LinkedIn::Client.new
    linked_in.authorize_from_access(detail.token, detail.secret)
    linked_in_client ||= linked_in
  end

Comments