.. rst-class:: book-body ========================================================== Linked in Capabilities ========================================================== :author: Thava Alagu thavamuni@gmail.com :Version: 0.8 :Date: |date| :status: Draft .. |date| date:: %Y %B %d ----- .. sidebar:: Contents .. contents:: :local: :depth: 3 .. sectnum:: :depth: 3 Links ===== * http://developer.linkedin.com * Register your application: http://www.linkedin.com/secure/developer * Project Voldemort, etc. http://data.linkedin.com * http://apigee.com/console/linkedin * List API http://electric-meadow-1119.herokuapp.com/linkedin * From linkedin labs: - http://resume.linkedinlabs.com - http://timeline.linkedinlabs.com - http://instant.linkedinlabs.com - Ajax api. - inreview ? linkedinlabs.com - Pure javascript API. * Harsh Singhal links__ * 9 ways to add linkedin__ .. __: https://github.com/harshsinghal/LinkedIn-API-WebFrameworks/blob/master/HACKDAY-RESOURCES.md .. __: http://mashable.com/2012/04/03/linkedin-website-plugins/ Getting Started =============== * Register Your Application: https://www.linkedin.com/secure/developer * LinkedIn uses the OAuth 1.0a protocol * Get your oauth keys * Access your own profile. See `Accessing Self Profile`_ * Applications can sign-in on behalf of users -- For that you need to use OAuth 1.0a protocol. Fine granular permission can be granted by your users to the application. * you can configure your application as to how the user should be redirected on successful authentication. * See http://oauth.net/code/ for example oauth code in all languages. * There is a walkthrough on using oauth plugin with PHP here: http://toys.lerdorf.com/archives/50-Using-pecloauth-to-post-to-Twitter.html * See `Oauth Steps`_ for exact steps. * Linked in does not seem to have API for accept-invitation. See `Linkedin-Permissions`_ * Also See: - API Resource map: https://developer.linkedin.com/documents/linkedin-api-resource-map * See `API Notes`_ Motivation ========== * Allow registration and signin easier -- use linked in identity * Allow linked-in profile plugin on 3rd party website-- maks the website more useful. * Share your activities to Linkedin Using sharing API Accessing Self Profile ====================== Here is how in PHP:: // Fill the keys and secrets you retrieved after registering your app $oauth = new OAuth("abcd123456", "efgh987654"); // apikey, secretkey $oauth->setToken("abcd1234-efgh987-9988", "9876abcd-123asdf-1122"); // user-token, user-secret $params = array(); $headers = array(); $method = OAUTH_HTTP_METHOD_GET; // Specify LinkedIn API endpoint to retrieve your own profile $url = "http://api.linkedin.com/v1/people/~"; // By default, the LinkedIn API responses are in XML format. If you prefer JSON, simply specify the format in your call // $url = "http://api.linkedin.com/v1/people/~?format=json"; // Make call to LinkedIn to retrieve your own profile $oauth->fetch($url, $params, $method, $headers); echo $oauth->getLastResponse(); Here is what you get in JSON:: { "firstName": "Kamyar", "headline": "Senior Partner Engineer at LinkedIn", "lastName": "Mohager", "siteStandardProfileRequest": { "url": "http://www.linkedin.com/profile?viewProfile=&key=8219502&authToken=SqI1&authType=name&trk=api*a108281*s116823*" } } Do json_decode to convert:: array(5) { ["a"] => int(1) ["b"] => int(2) ["c"] => int(3) ["d"] => int(4) ["e"] => int(5) } Oauth Steps =========== * Authorize the application. The end result is you get the request_token :: import oauth2 as oauth import urlparse   consumer_key           = "XXXXXXXXXXX" consumer_secret       = "XXXXXXXXXXX" request_token_url      = 'https://api.linkedin.com/uas/oauth/requestToken' // <=== POST access_token_url = 'https://api.linkedin.com/uas/oauth/accessToken' authorize_url = 'https://www.linkedin.com/uas/oauth/authenticate' consumer = oauth.Consumer(consumer_key, consumer_secret) resp, content = client.request(request_token_url, "POST")   request_token = dict(urlparse.parse_qsl(content)) Linkedin-Permissions ==================== * Few levels of permissions to get all your profile data * Retrieve and post updates to LinkedIn as you * Retrieve and post group discussions as you * Send messages and invitations to connect as you API Notes ========= * Primary email available via profile API * http://api.linkedin.com/uas/oauth/requestToken?scope=r_basicprofile+r_emailaddress * Plugins- Share, AWLI, Member Profile, Sign-in with linked in