1   Linked in Capabilities

author:Thava Alagu thavamuni@gmail.com
Version:0.8
Date:2016 October 07
status:Draft

1.2   Getting Started

1.3   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

1.4   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:

<?php
$json = '{"a":1,"b":2,"c":3,"d":4,"e":5}';

var_dump(json_decode($json, true));  /* true for associative array result */

?>
array(5) {
  ["a"] => int(1)
  ["b"] => int(2)
  ["c"] => int(3)
  ["d"] => int(4)
  ["e"] => int(5)
}

1.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))
    

1.6   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

1.7   API Notes