hexgnu / linkedin Goto Github PK
View Code? Open in Web Editor NEWRuby wrapper for the LinkedIn API
Home Page: http://rdoc.info/gems/linkedin
License: MIT License
Ruby wrapper for the LinkedIn API
Home Page: http://rdoc.info/gems/linkedin
License: MIT License
This is somewhat a continuation of: http://github.com/pengwynn/linkedin/issues/closed#issue/3
Basically, without knowing you have to explicitly set which fields to include, you're completely out of luck. I burned time on it awhile before I stumbled the closed issue that solved it. ;) Not sure if you've updated the docs at all (I couldn't find it), but I'd heavily suggest doing that.
Along those lines- not sure if there's a way around this whole process, but it did seem pretty non-intuitive to me. It'd be nice to get at those fields without explicitly stating them.
And as a final, last related note: this feels really weird to have to do:
client.profile(:fields => [:educations]).education
To pluralize, or not to pluralize; that is the question. Thanks though, now that I figured out the :fields trick; sorry for a vague, loosely-connected ticket!
Not sure if its a Linkedin API problem or problem with wrapper.
Looking for it with puts profile.picture_url
Looks like LinkedIn has a /authenticate URL instead of /authorize to support better one-click signing.
Here is what changes:
opts = {
:request_token_path => "/uas/oauth/requestToken",
:access_token_path => "/uas/oauth/accessToken",
:authorize_path => "/uas/oauth/authenticate"
}
It prevents each 'login' from making the user click the "Authorize" button which may not be bad.. perhaps this could be configurable in the construction of the client.
Whenever I try to post or clear a status update I get this message.
ruby-1.9.2-p0 > require 'linkedin'
NoMethodError: undefined method delegate' for ROXML::XMLRef:Class from /Users/igrigorik/.rvm/gems/ruby-1.9.2-p0/gems/roxml-3.1.5/lib/roxml/xml/references.rb:10:in
class:XMLRef'
from /Users/igrigorik/.rvm/gems/ruby-1.9.2-p0/gems/roxml-3.1.5/lib/roxml/xml/references.rb:8:in <module:ROXML>' from /Users/igrigorik/.rvm/gems/ruby-1.9.2-p0/gems/roxml-3.1.5/lib/roxml/xml/references.rb:1:in
<top (required)>'
When trying to retrieve network updates for a given user, the returned Mash doesn't seem to allow you to access the update_content within an update object.
# controller
@network_updates = @linkedin_client.network_updates
# view
@network_updates.updates.each do |update|
update.respond_to?(:update_content)
end
The following will always return false for every update object despite the fact that upon inspection, there is definitely an update-content Nokogiri XML node.
We upgraded from 0.2.2 to 0.3.2 some time ago, but have just now noticed that status updates seemed to be removed. It looks like there are commits that indicate an intent to refactor, but the 0.3.2 version seems not to contain this capability.
We had been using this gem in a larger app and are wondering if this functionality will be added back in at some point.
Having the company API is great, but I'd love to pull the user's company from their profile. See profile API docs here and look at the company section right below positions: https://developer.linkedin.com/documents/profile-fields
I am not sure if i am using this right. I did some search with:
people=client.search(:options...) and it does return some people. But the education is an empty array if I do this: people.profiles[0].education. However, I can tell that person's linkedin profile (from the web) does have some education information. Am I miss something in here?
Thanks
James
After authorizing a client via authorize_from_request, the value for client.profile.id is always nil, other values like first_name are populated though.
...
LinkedIn::Client.new(linked_in['key'], linked_in['secret'])
atoken, asecret = client.authorize_from_request(token, secret, pin)
puts client.profile.id # nil
puts client.profile.first_name #'Will'
is it possible I'm not getting the full profile when authorizing this way?
Why am I getting this error? I get the atoken and asecret from the authentication hash after using OmniAuth. Seems okay, but then when I try to access the profile method, it borks:
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 if @user == current_user
12 @client.profile
13 else
14 @client.profile(:id => @user.uid)
15 end
16 end
Today the code to get the public profile of yourself:
@Profile = client.profile :fields => , :public => true
It seems useless to have to pass the :fields key in this case.
To fix that, you just have to modify this part of the client.rb code:
unless options[:fields].nil?
if options[:public]
path +=":public"
else
path +=":(#{options[:fields].map{|f| f.to_s.gsub("_","-")}.join(',')})"
end
end
if you try to do a search by company, for example, with accentuated characters in the company name, open-uri crashes with URI::InvalidComponentError. it seems that we should URI escape the options before passing them to open-uri.
how do i send invation to linkedin user by email??
Hi,
I've two questions:
it seems client.profile(:id => 'gNma67_AdI', :fields => %w(first-name, last-name, headline, positions, education)) doesn't work on rails 3.
The result (as for any valid id) is:
LinkedIn::RateLimitExceeded in OauthController#callback (400): Bad Request - 0
how can I get as much information as I want concerning the logged in user (ie profile picture per example)? I don't know how to get it's id.
Thanks in advance!
Almost everywhere the subclasses liked Position, Company, etc, are used, they need to be scoped to be LinkedIn::Position, LinkedIn::Company, etc.
We have a models in our app called Company and Education, and the linkedin plugin blows up when it calls:
Company.new(@position.xpath('./company'))
because it is trying to use our model instead of LinkedIn::Company.
When trying to access education's field_of_study, I found it was inside end_date as it return a hash!!
@Profile = client.profile(:fields => %w(first-name last-name positions educations location industry))
@profile.education.first.field_of_study # undefined method
@profile.education.first.end_date["field-of-study"] # very strange
Accessing field is a bit tricky :(
testing api
I get Gem::Exception: can't activate oauth (~> 0.3.5, runtime) for ["linkedin-0.1.7"], already activated oauth-0.4.0 for [] because I have oauth0.4.0, does this need to hardcoded?
linkedin at /home/camoedo/.rvm/gems/ruby-1.9.2-p136/bundler/gems/linkedin-3d694f1d9bb3 did not have a valid gemspec.
This prevents bundler from installing bins or native extensions, but that may not affect its functionality.
The validation message from Rubygems was:
["test/client_test.rb", "test/fixtures/blank.xml", "test/fixtures/connections.xml", "test/fixtures/error.xml", "test/fixtures/network_status_with_group.xml", "test/fixtures/network_statuses.xml", "test/fixtures/picture_updates.xml", "test/fixtures/profile.xml", "test/fixtures/profile_full.xml", "test/fixtures/profile_with_positions.xml", "test/fixtures/search.xml", "test/fixtures/status.xml", "test/oauth_test.rb", "test/test_helper.rb"] are not files
Thanks for your effort!
Hi,
Nice work with this gem btw.
From the LnkedIn api doc, we can pass Accept-Language to get the profile info based on our locale,
How can i pass it using your gem?
Regards
Occasionally, my app seems to be receiving unexpected 401 error responses from the LinkedIn API, confusing the error-handling in the linked in gem. More specifically, the API appears to be returning an HTML payload, but the gem expects JSON.
MultiJson::DecodeError: 743: unexpected token at '<html><head><title>Apache Tomcat/6.0.32 - Error report</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 401 - </h1><HR size="1" noshade="noshade"><p><b>type</b> Status report</p><p><b>message</b> <u></u></p><p><b>description</b> <u>This request requires HTTP authentication ().</u></p><HR size="1" noshade="noshade"><h3>Apache Tomcat/6.0.32</h3></body></html>'
Here's the corresponding backtrace:
.bundle/gems/ruby/1.9.1/gems/json-1.6.0/lib/json/common.rb:148:in `parse'
.bundle/gems/ruby/1.9.1/gems/json-1.6.0/lib/json/common.rb:148:in `parse'
.bundle/gems/ruby/1.9.1/gems/multi_json-1.0.3/lib/multi_json/engines/json_gem.rb:13:in `decode'
.bundle/gems/ruby/1.9.1/gems/multi_json-1.0.3/lib/multi_json.rb:65:in `decode'
.bundle/gems/ruby/1.9.1/gems/linkedin-0.3.2/lib/linked_in/mash.rb:9:in `from_json'
.bundle/gems/ruby/1.9.1/gems/linkedin-0.3.2/lib/linked_in/helpers/request.rb:45:in `raise_errors'
.bundle/gems/ruby/1.9.1/gems/linkedin-0.3.2/lib/linked_in/helpers/request.rb:16:in `get'
.bundle/gems/ruby/1.9.1/gems/linkedin-0.3.2/lib/linked_in/api/query_methods.rb:32:in `simple_query'
.bundle/gems/ruby/1.9.1/gems/linkedin-0.3.2/lib/linked_in/api/query_methods.rb:8:in `profile'
[PROJECT_ROOT]models/linked_in_profile.rb:14:in `find'
I think the gem needs to be more resilient in the face of this type of error.
I could n't install the Linked gem and omniauth gem together because Omniauth 1.0 supports only hashie > 1.2 but linkedin only support hashie>1.1.0
I'm trying to get the linkedin gem to work, but I get this error:
can't activate oauth (~> 0.3.5, runtime) for ["linkedin-0.1.7"], already activated oauth-0.4.0 for ["twitter_oauth-0.3.6"]
Anyone know the workaround?
I want to use the Apigee API proxy so I can better manage and debug the LinkedIn API.
To do that, I need to send all traffic through the proxy. How can I change the URI?
Thanks!
I've been using the #share method to post shares to people's profiles using the following code:
client = LinkedIn::Client.new(...)
client.authorize_from_access(...)
client.share(:comment => "Hello World")
Starting sometime this weekend, LinkedIn's API began returning a 500 response to every attempt I made at this request. I posted this to their developer forum and they responded that its a bug on their end related to XML parsing: https://developer.linkedin.com/forum/getting-500-error-response-v1peopleshares
By trial and error, I figured out a way to get the above code working again. With just a comment, you can remove the content node in the XML. I monkey patched the #share_to_xml function to implement this work around:
LinkedIn::Client.class_eval {
private
def share_to_xml(options={})
doc = Nokogiri.XML('<share><comment/><content><title/><submitted-url/><submitted-image-url/></content><visibility><code/></visibility></share>')
doc.encoding = 'UTF-8'
{:comment => 'comment', :title => 'title', :url => 'submitted-url', :image_url => 'submitted-image-url'}.each do |key, name|
doc.at_css(name).content = options[key] if options[key]
end
doc.at_css('visibility > code').content = options[:visibility] || options[:visability] # backward-compatible typo fix
### MONKEY ###
content_fields = [:title, :url, :image_url]
unless options.values_at(content_fields).compact.any?
doc.xpath('//content').remove
end
### MONKEY ###
doc.to_xml
end
}
I asked on the forum if they are going to fix the issue. If they respond and say they aren't or don't respond, I can do a proper patch and submit a Pull Request
In case of special characters in the linkedin message subject and body the LinkedIn::Message#to_xml generates invalid xml.
Please escape subject and text in the linkedin message xml.
I used the following as an example: client.profile(:fields => "picture_url") and I got the following:
#<LinkedIn::Profile:0xb6808a98 @doc=#<Nokogiri::XML::Document:0x..fdb404506 name="document" children=[#<Nokogiri::XML::Element:0x..fdb40436c name="person" children=[#<Nokogiri::XML::Text:0x..fdb40422c "\n ">, #<Nokogiri::XML::Element:0x..fdb404204 name="picture-url" children=[#<Nokogiri::XML::Text:0x..fdb404088 "http://media.linkedin.com/mpr/mprx/0_zVjRUCzvdQg-C7R8z4VHUhCvd3Zr82R8BjdkU31k9MpDczTbEF74fiIVuqJ0LNQTDbxnH">]>, #<Nokogiri::XML::Text:0x..fdb403e94 "\n">]>]>>"
How do I access the specific element I want to reach. The class of object is LinkedIn::Profile, but I want the Nokogiri doc....
Thanks...
public-profile-url field is missing from this gem.
See last row of General Profile Fields:
http://developer.linkedin.com/docs/DOC-1061
The search implemented is deprecated. There is a new "people-search" api:
http://developer.linkedin.com/docs/DOC-1191
I am trying to use the search API and am not clear how to use this once Oauth has been completed since the gem does not include those methods...
Can't seem to find one...
After the OAuth authorization and verification is done and you have auth_token and auth_secret, making a profile request fails because URL is not setup correctly on client. Hence the request fails with the following trace:
oauth (0.4.5) lib/oauth/request_proxy/base.rb:94:in `normalized_uri'
oauth (0.4.5) lib/oauth/request_proxy/base.rb:114:in `signature_base_string'
oauth (0.4.5) lib/oauth/signature/base.rb:77:in `signature_base_string'
oauth (0.4.5) lib/oauth/signature/hmac/base.rb:12:in `digest'
oauth (0.4.5) lib/oauth/signature/base.rb:65:in `signature'
oauth (0.4.5) lib/oauth/signature.rb:23:in `sign'
oauth (0.4.5) lib/oauth/client/helper.rb:45:in `signature'
oauth (0.4.5) lib/oauth/client/helper.rb:75:in `header'
oauth (0.4.5) lib/oauth/client/net_http.rb:91:in `set_oauth_header'
oauth (0.4.5) lib/oauth/client/net_http.rb:30:in `oauth!'
oauth (0.4.5) lib/oauth/consumer.rb:227:in `sign!'
oauth (0.4.5) lib/oauth/consumer.rb:191:in `create_signed_request'
oauth (0.4.5) lib/oauth/consumer.rb:162:in `request'
oauth (0.4.5) lib/oauth/tokens/consumer_token.rb:25:in `request'
oauth (0.4.5) lib/oauth/tokens/access_token.rb:12:in `request'
oauth (0.4.5) lib/oauth/tokens/access_token.rb:27:in `get'
linkedin (0.3.1) lib/linked_in/helpers/request.rb:15:in `get'
linkedin (0.3.1) lib/linked_in/api/query_methods.rb:32:in `simple_query'
linkedin (0.3.1) lib/linked_in/api/query_methods.rb:8:in `profile'
A workaround is to make a "client.request_token" call before a profile call that will setup the api request target site properly. My current monkey patch is to add the make the path in lib/helpers/request_helpers.rb include "https://api.linkedin.com", but not sure if this is the right fix.
Hello, for a given 2nd degree connection to a User, I want to use this field described in the API documents, but not sure what the () means in terms of accessing it using the linkedin gem?
How would I list the person objects that are the 1st-degree connections to those selected 2nd degrees?
We implemented some features using linkedin 0.2.2 and everything works fine most of the time. Occasionally we are receiving OAuth::Problem token_rejected errors during the authorize_from_request method.
I have looked at Tips on Debugging OAuth Problems on LinkedIn's developer docs, but I don't think any of those are relevant.
I'm fairly new to the whole OAuth dance, has anyone else experienced anything similar?
Hi,
I am trying to do something pretty simple (I think) where I call:
client.network_updates
I can get fields like timestamp, update_key, update_type, etc. just fine. However, when I try to get the first-name field (or any of the ones in the node (see the sample XML in http://developer.linkedin.com/docs/DOC-1006), I am stumped.
Can you point me in the right direction here?
Thanks!
I'm probably missing something, but I'd like to be able to specify a network update type in a call to network_updates. I guessed it would be something like: client.network_updates(:type => 'SHAR')
but that returns all update types in the stream - CONN, PROF, STAT, etc. Ideally, I'd like to require multiple types such as SHAR and STAT.
Perhaps this is related to Issue #76 since specifying a count parameter doesn't seem to work either?
It looks like from the desktop I get the authorization URL to get the pin.
It looks like I can use request_token.params[:oauth_token] ...these are the same?
Hi, I won't re-fork the project for a dependency update :)
The linkedin gem requires oauth 0.3.x, but 0.4.0 is out and no compatibility problem should happen.
When I include this gem in my project, it breaks webrat in my integration tests. In my case, it is the fill_in method that generates the following error:
NoMethodError: undefined method `has_key?' for #Nokogiri::XML::Element:0x102f827a0
I've tried to hunt where the error comes from and, in webrat, file lib/webrat/core/locators/field_by_id_locator.rb in line 22 (field_elements method) there is a call to @dom.xpath(*Field.xpath_search) which returns a Nokogiri::XML::NodeSet.
Without the linkedin gem in my project:
@dom.xpath(*Field.xpath_search).first.attributes.class #=> Hash
With the linkedin gem included:
@dom.xpath(*Field.xpath_search).first.attributes.class #=> Nokogiri::XML::Element
So it's naturally expecting attributes as a Hash, but whenever I include the linkedin gem, it returns a Nokogiri::XML::Element instead.
My environment:
webrat (0.6.0)
Ruby version 1.8.7 (universal-darwin10.0)
RubyGems version 1.3.5
Rack version 1.0
Rails version 2.3.4
Active Record version 2.3.4
Active Resource version 2.3.4
Action Mailer version 2.3.4
Active Support version 2.3.4
Environment development
Database adapter sqlite3
Thank you - one other quick question. I have pulled down the 2-0 branch and built a Gem that I am using, when I drill down deep enough into the groups API or call groups from Profile, I keep getting the following error:
undefined method `decorate' for nil:NilClass
Any ideas?
Thank you,
Daniel
I use the following:
client.profile(:id => linkedin_uid)
I get this error:
LinkedIn::NotFound: (404): Not Found
pull request send
Hi,
I must have missed something, but the current gem version (0.3.2) seems to have all API methods commented out. I searched the gem source for the update_status
method, and except for the call in the example, it's only defined in lib/linked_in/api/update_methods.rb
, but everything in there is commented out!
Why is this so, and why is not the latest published gem working normally?
Hi there
I'm having issues pulling anything decent out of client.profile...
All I end up with is a short hash:
I'm calling using the following in my model:
require 'linkedin'
class LinkedinToken < ConsumerToken
def index
client = LinkedIn::Client.new(LinkedinToken.consumer.key, LinkedinToken.consumer.secret)
client.authorize_from_access(token, secret)
@client = client.profile
end
end
Interestingly, I can view the current connections and post updates fine.
Is there something stupid I'm doing wrong?
Simon
I am trying to utilize the new groups API - and curious if this GEM has the methods for it?
I am trying to send a tag that doesn't get read as a straight-up string through update_status to linked in...but I can't seem to create it....how do I pass it so that LinkedIn displays it as a hyperlink, not just rendering the -tags?
I've struggled for countless hours now trying to figure out how to get the pin (oauth_verifier) into the mix without user interaction. I thought it was easy enough just getting the oauth_verifier from params but I keep getting permission_unkown in this line:
If someone could point me in the right direction I'd be grateful. I have created a minimal project that uses devise, omniauth-linkedin and obviously this gem here: https://github.com/wulffeld/test-linkedin-devise-omniauth
It's mongodb based so if you have mongodb running it should work more or less out of the box - just add a config.yml file in config with the key/secret:
development:
linkedin_key: MYKEY
linkedin_secret: MYSECRET
On the home page click 'Sign in' then 'Sign in with Linkedin' to auth with LinkedIn.
After that just hit the /connections url and the error should appear.
If i do the example (at https://github.com/pengwynn/linkedin) where I manually get the pin it works just fine.
Hi, I'm having difficulties retrieving the picture url from the search api. Is this possible at all?
Im trying to update the status or share something with v0-2-stable, but when I tried:
client.update_status "test"
undefined method `update_status' for #LinkedIn::Client:0xb64c0584
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.