1

I have been trying to use the LinkedIn gem (0.3.6) to search. I can successfully authenticate and search with just keywords but I want to be able to use the field selectors so that my results contain more than just id, first name, last name.

I have been unsuccessful when doing what is in the spec

 fields = [{:people => [:id, :first_name, :last_name, :public_profile_url, :picture_url]}, :num_results]
        client.search(:first_name => 'Giliardi', :last_name => 'Pires', :fields => fields)

Has anyone been able to get this to work?

CountCet
  • 4,545
  • 7
  • 30
  • 39

1 Answers1

0

It seems that the gem client.search does not match the github client.search... and the spec is based on the github client.search. And to be honest I cannot figure out how to get it to work with the Gem search. They do not include a spec for search in the Gem example provided in the api_spec.rb (no search_spec) gives a 404: client.search(:first_name => "Javan", :fields => ["num_results", "total"])

My suggestion would to be build the gem from the github source and use the selectors.

Gem:

def search(options={})
      path = "/people-search"
  options = { :keywords => options } if options.is_a?(String)

  if fields = options.delete(:fields)
    path +=":(#{fields.map{ |f| f.to_s.gsub("_","-") }.join(',')})"
  end

  options = format_options_for_query(options)

  result_json = get(to_uri(path, options))
  Mash.from_json(result_json)
end

GitHub:

def search(options={})
  path = "/people-search"

  if options.is_a?(Hash)
    fields = options.delete(:fields)
    path += field_selector(fields) if fields
    puts path
  end

  options = { :keywords => options } if options.is_a?(String)
  options = format_options_for_query(options)

  result_json = get(to_uri(path, options))

  Mash.from_json(result_json)
end
ScottJShea
  • 7,041
  • 11
  • 44
  • 67