I am using the linkedin gem https://github.com/pengwynn/linkedin
I authorize using Omniauth and store the access token and secrets.
I then authorize by access with the client.
I appear to get something useful when I type client.profile — but it looks like mostly Nokogiri but in a LinkedIn::Profile class.
How do I specifically access fields, and will I be able to use method calls from the View in rails or do I need to do all the parsing in the controller and pass those values to the View from there.
Example of how to access the profile image url, title, name, company that sort of thing once I have established client.profile would be great.
When I use the (:fields =>) I get back something like this:
#<LinkedIn::Profile:0xb682c72c @doc=#<Nokogiri::XML::Document:0x..fdb41630a name="document" children=[#<Nokogiri::XML::Element:0x..fdb415fae name="person" children=[#<Nokogiri::XML::Text:0x..fdb415d88 "\n ">, #<Nokogiri::XML::Element:0x..fdb415d24 name="picture-url" children=[#<Nokogiri::XML::Text:0x..fdb415aae "http://media.linkedis:
I just want the string associated with the node “picture-url”…how do I do that?
From controller:
7 `def show`
8 @user = User.find(params[:id])
9 @client = LinkedIn::Client.new(ENV["LINKEDIN_KEY"], ENV["LINKEDIN_SECRET"])
10 @client.authorize_from_access(@user.atoken, @user.asecret)
11 @client.profile(:id => @user.uid, :fields => ["picture-url", "headline"])
12
13 end
New error:
undefined method `downcase' for nil:NilClass
Here is a related question: “https://stackoverflow.com/questions/5821549/how-do-i-pass-a-a-tag-through-ruby-to-linkedin-using-the-gem“
I did it by adding:
This would then allow me to access specific positions or fields without going into the raw xml, just using the methods in the gem. The gem works nicely once I get the format…