By brandon.corbin on Thursday December 11th, 2008

  LinkedIn Profile API v.1.5 (7.0 KiB, 957 hits)

Update 5/1/2010:
I have updated the example to the proper URL http://icorbin.com/code/linkedin/profile/1.5/

UPDATE 4/27/2010:
I have rewritten the LinkedIn Profile Parser to leverage PHP’s DOMDocument. No longer are we reliant on a 3rd party to parse the initial profile html…

Presenting the open source PHP LinkedIn Public Profile API, released under the OSL 3.0

How does it work?
This PHP Class (requires php5) imports a users LinkedIn public profile (by supplying their public profile username) and turns the results in to a simple XML document.

You can see my example at http://icorbin.com/code/linkedin/profile/1.5/

How do you use it?
Inside you will find 3 files.
1. linkedin.php – the actual PHP Class (requires PHP5)
2. profile.php – an example of how to use the Class.
3. livingresume.xsl – the default XSL that is attached to the Users XML Profile.

Usage:

<?
include_once('linkedin.php');
$Profile=new LinkedInProfile('brandoncorbin', 'http://icorbin.com/work/linkedin/livingresume.xsl');
header("Content-Type:application/xml");
echo($Profile->getProfileXML()->asXML());
?>

Questions? Leave them in the Comments and I will reply ASAP.

Disclaimer: I offer absolutely no guarantees that this will work on your system. As a matter of fact, it’s possible that this script could ask you to play “global thermal nuclear war” – if it does, please answer no. We all know what about happened last time.

  LinkedIn Profile API v.1.5 (7.0 KiB, 957 hits)


40 Responses to “LinkedIn Profile API – NEW & IMPROVED!”

  1. portjump says:

    Hey Brandon -
    Fantastic idea! I’ve really been getting into using social media as a marketing tool and started doing my homepage updates with a twitter feed. Came across your page looking for a way to do the same thing with my LinkedIn public profile.

    Noticed your example doesn’t work, and I’m just wondering if that was due to LinkedIn shutting it down or something else…

    I’m trying to do this script in ASP, so I was going to use this as a basis. If I manage to pull it off, I’d be happy to share for you to re-post.

    -Pete

    • Pete, by now, I am sure that linkedin is rejecting requests from the html2xml service that I was using – but finding another service would remedy the problem :) – And I would absolutely love to hear if you end up porting it over to asp, that would be pretty cool.

  2. portjump says:

    I did see something on their blog that they decided to make their own widget to be able to allow you to include it on your website, but it’s still not as flexible as what you were doing. It’s really to bad they stifled your development rather than embracing it.

  3. Eric says:

    Hey Brandon,

    Your code seems to work fine. Great. I have just one problem (and i’m not a php expert..). Its just loads one job, education etc. The loop is working fine ($experience) and has got the right content (more jobs), but its doesn’t save it in the job array ($this->profilexml->jobs->job[$i]->..) Any idea?

    • Hey Eric, it might be that they modified their Jobs list basic HTML which could make the parser no longer find it… If they have changed it, then the change will need to be reflected in the Xpath call… Does that help?

  4. Nitin says:

    http://brandonshead.com/work/linkedinProfile.zip link is not work so how i can download the linkedin open source API.

    Please help me..

  5. Nitin says:

    thanks for the reply.

    Can you please provide me a link for download linkedinProfile.zip file.

    Please help me.

    thanks
    nitin

  6. Varun says:

    Hi,
    Iam using your linked in api and iam able to dispaly user id of the logged in user. Now i want to provide an interface in my own website where user can able to login in linkedin through my website. Please provide the details ASAP.

    Thanks in advance.

    • Hey Varun, unfortunately I don’t have the time to write some code for you to use – but if all you are looking for is a the form fields (username,password) and where to send the POST to – check out how LinkedIn handles it at https://www.linkedin.com/secure/login

      You should be able to take the basic code, and post it straight to the same page “https://www.linkedin.com/secure/login”

  7. Varun says:

    Hi Brandon,
    If you are able to provide me some code for login in linkedin, that would be a great help. What my plan is to provide own login page to the user. as soon as user feed the informations. page should redirect to linkedin page, if he/she has selected to use linkedin facility. [means single sign on facility for my and linkedin website].

    Thanks in advance,
    Varun

  8. [...] June 09 3 Comments Category: Products, Usability Hello there! If you are new here, you might want to subscribe to the RSS feed for updates on this topic.This post is out of date – check out this post to learn more about the updated LinkedIn Profile API [...]

  9. Clinton says:

    Nice class. Would like to see access to the updates (or news feed as Facebook refers to it)

  10. Simon says:

    hello dear ,

    this is simon i m making a social networking site and need linkedin api to my blog . i use ur api its realy outstanding , but there is some problem in XML parser so plz help me to make it …….. thanks for this post .

  11. Jason r says:

    Anyone have a suggestion for what to replace the html2xml.nl link with since that site no longer exists??

  12. Mats says:

    What am I missing? I get a bunch of these error messages:

    Warning: DOMDocument::loadHTML() [function.DOMDocument-loadHTML]: htmlParseEntityRef: expecting ‘;’ in Entity, line: 175 in /var/www/linkedin/linkedin.php on line 77

  13. Matt, what’s the LinkedIN profile you’re trying to pull in? Want to see if there are any special characters in it – as it would appear those are breaking the $doc->loadHTML( $this->profileHTML);

  14. Mats says:

    Line 77 on loadHTML (I guess)
    I just installed your files for test at http://87.96.164.4/kexxio/linkedin/

  15. Mats says:

    I’m just working on the default example, ie your profile

    • Matt, this is the first time I have seen this – interesting for sure. What version of PHP are you running? Windows Linux?

      Also, try to add an @ on Line 77 – so it looks like

      @$doc->loadHTML( $this->profileHTML);

  16. Mats says:

    PHP 5.2.4 on Ubuntu Linux
    Well with the added @ there is only 1 error on line 205…

  17. Mats says:

    Brilliant! That did it :-)
    Thanks for everything.

  18. PHPdude says:

    Windows says the zip fileis not valid!

  19. PHPDude, I dont have a Windows machine, but was able to unzip it from Ubuntu as well. Has anyone else had this problem?

  20. PHPdude says:

    Thanks for the quick response. I was able to open it using zip-7. For some reason the native windows vista “extract” option does not like that zip encoding.

  21. Thanks for the heads up, Ill try to take a look at it this evening and see if I can get a Windows friendly archive going…

  22. Scott Gregor says:

    Hi Brandon,

    My name is Scott, I tripped over your site while conducting a search for solid PHP developers on Linkedin through Google. Since I’m here I thought I’d ask if you knew of anybody looking for work. I have a cool opportunity with a well known web based technology firm looking for a “contractor” for 6 months. I have job specs and etc. Feel free to contact me and thanks for your time.

  23. Mahesh Baral says:

    Hi Brandon,

    I cannot find a download link for the new version that doesnot use Html2Xml. http://brandonshead.com/work/linkedinProfile.zip link gives me the old version.

  24. Bryan says:

    Hi Brandon:

    I have problem on getting properly run your script, I have not touch any code of the script, I just simply upload and test it on the site. And this error message occurs:

    “This page contains the following errors:

    error on line 2 at column 1: Extra content at the end of the document
    Below is a rendering of the page up to the first error.”

    Thanks in Advance!

  25. Ilyas Kazi says:

    Hi Brandon,

    I got the error message in a big red box saying…

    “This page contains the following errors:

    error on line 2 at column 1: Extra content at the end of the document
    Below is a rendering of the page up to the first error.”

    …and I don’t see any output.

    I am running through localhost in my WAMP and have configured as per your index page.
    my username is ilyaskazi.

    Could you please help me in that?

    • Ilyas, on the linkedin.php file – can you look at line 77 and tell me if it looks like :

      @$doc->loadHTML( $this->profileHTML);

      If it’s missing the @ at the beginning, add it and see if that fixes the problem.

      • Ilyas Kazi says:

        Yea.. it was missing and now fixed!

        Here I confirm.. I checked with chrome-5, firefox-3 and iexplorer-8 and working absolutely fine.

        Thank you for this gr8 hack..

Leave a Reply

← By brandon.corbin

I am Brandon Corbin, a web entrepreneur with a background in advertising and design. For over a decade I have applied my passion for user experience, marketing and software design to industries like: radio, real estate, pharmaceuticals, recruiting and eCommerce.