LinkedIn Profile API v.1.6 (7.2 KiB, 2,572 hits)
Update 2/23/2011: Version 1.6
LinkedIN Made some changes to it’s public profile pages HTML – thus breaking most of the selectors. This has now been updated. http://icorbin.com/code/linkedin/profile/1.6/
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.6 (7.2 KiB, 2,572 hits)


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.
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.
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?
http://brandonshead.com/work/linkedinProfile.zip link is not work so how i can download the linkedin open source API.
Please help me..
Hey Nitin, I have updated the link and it is now available. Sorry about that, I lost it while moving from my previous host!
Thanks! Brandon
thanks for the reply.
Can you please provide me a link for download linkedinProfile.zip file.
Please help me.
thanks
nitin
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”
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
[...] 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 [...]
Nice class. Would like to see access to the updates (or news feed as Facebook refers to it)
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 .
Simon, what seems to be the problem?
Anyone have a suggestion for what to replace the html2xml.nl link with since that site no longer exists??
Damn I wonder when HTML2xml went away. What version of PHP are you running? I’ll play around with using PHPQuery as a new method for extracting the data…
Jason, I have updated the class to use PHP’s DOMDocument object – and everything is working just dandy… http://icorbin.com/code/linkedin/profile/1.5/
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
Matt, what Line number is that happening on? – oh line 77 – sorry, didn’t see the whole comment in my Admin…
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);
Line 77 on loadHTML (I guess)
I just installed your files for test at http://87.96.164.4/kexxio/linkedin/
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);
PHP 5.2.4 on Ubuntu Linux
Well with the added @ there is only 1 error on line 205…
lets see if its encoding …
Make line 205 –
$this->profilexml->affiliations->affiliation[$i] = htmlentities(trim($affiliation->span));
Brilliant! That did it
Thanks for everything.
Windows says the zip fileis not valid!
PHPDude, I dont have a Windows machine, but was able to unzip it from Ubuntu as well. Has anyone else had this problem?
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.
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…
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.
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.
Hi Mahesh, for some reason my Download link went “inactive” – it’s now backup and running. You can download the file at http://icorbin.com/?dl_id=3
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!
Hi Bryan, could you email me the URL so I can see the error in more depth? It looks like there is an extra line break (or something) that’s causing the XML to fail (my guess). hit me up at [email protected]
Hi Brandon:
Thanks for the reply, here is the link: http://www.skylinetest2.net/linkedin/.
I have noticed also that in firefox in gives another error:
“XML Parsing Error: junk after document element
Location: http://www.skylinetest2.net/linkedin/
Line Number 2, Column 1:Warning: DOMDocument::loadHTML() [domdocument.loadhtml]: htmlParseEntityRef: expecting ‘;’ in Entity, line: 520 in /home/skyline2/public_html/linkedin/linkedin.php on line 77
^”
The first error is on the google chrome browser.
Thanks Again!
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.
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..
Hello,
The same error has occur again. Earlier it was working by fixing with @ on line#77… but no more??
Could you look that..
What error are you seeing now?
What an great API! After changing line 77 (the extra @) i got it working, sort of. I only get my one work experience up, no education and error on the group icons.
http://macody.no/linkedin/
vs
http://www.linkedin.com/in/caspar
Any thoughts?
Caspar
Caspar, mmm that’s really weird. I wonder if it has to do with the name of your Education “Handelshøyskolen” – I will play around with it and see if I can figure out what’s going on. – Brandon
Caspar, what hosting Operating System are you using, and what version of PHP? Using the one that I have on my server with your information renders it – http://icorbin.com/code/linkedin/profile/1.5/?member=caspar
Strange…
Here’s the phpinfo URL: http://macody.no/linkedin/info.php
I tested with your LinkedIn profile with no luck: http://macody.no/linkedin/2/
This is really weird. Has anyone else seen this type of differences when dealing with XSL transformation?
Brandon,
Is it possible to do a data pull on LinkedIn companies. For example, say I wanted all “accounting” companies with less than 200 employees exported to excel or a txt file?
Thanks
Mb…. That’s a great question. It looks like LinkedIn has a company directory at http://www.linkedin.com/directory/companies/ it would be possible to scrap this to get company names. Then you would need to look up (maybe using YQL) the details about that company. It’s doable, but I dont think anything is out there to do it… yet.
Brandon, thank you for the nice library. I had the same problem as Bryan (Extra content at the end of the document) and it was fixed after adding the @-symbol, as you explained.
1. I would correct this in the latest downloadable version
2. The zip does not contain a file profile.php, as stated in your introduction, but a file index.php
Kind regards
Bram, thanks for the suggestions – I’ll try to get on that this weekend… Sincerely, Brandon
Hello Brandon! I downloaded your scripts, version 1.5. However, it doesn’t work. When loading you xsl, I get an unknown error. Your profile is empty too:
http://icorbin.com/code/linkedin/profile/1.5/
Is there a bug you know of?
Thanks in advance!
Thijs
doesn’t look like this works anymore. any suggestions?
Dear Sir:
I downloaded your code last month and it works well. But today when i again run it. It only gives the groups information and nothing else. Then I come to your website again and check your profile. It showed the same result. can you please check and verify that what is problem and why it is ???
Thanks
Arif Amir
It looks like LinkedIn has updated their HTML a bit causing the breakage. I think I have made all the necessary changes. Feel free to download 1.6.
Respected Sir :
When I extract the 1.6.zip file it giver an error that archive is damaged. Please upload the files once again.
–Thanks–
Arif
Dear Sir :
I am waiting for your response.The zip file is corrupted or damaged. Please upload the files again.
–Regards–
Arif
Arif, what are you using to unzip it? It unzipped just fine on my mac…
Dan , Whenever I try to download the zip file, My downloader just stuck and after a while it says timeout.
Can u please email me the code on my mailing address.
[email protected]
Ok, I have updated the file. See if that works for you.
I want to use oAuth in your file.
User can login option then he or she get his full profile. But how do that?
Please help me.
how do i display recommendations?
Is there a way I can *sigh* JUST print the recommendations I have on LinkedIN, on my website? Your idea WORKED – which is amazing – but I can’t figure out how to alter it so that it only shows the recommendations.
SURE I could copy/paste them, but where’s the fun in that?
I just want them to go here: http://go-etree.com/testimonials so I can kick off that other junk where anyone could have posted it and no one knows if it’s legit or not. I’m so frustrated, and you’re a genius, so I thought I’d ask you. <3
Kathy and Danne,
Unfortunately, LinkedIn keeps recommendations out of the public profile, which this script pulls from. Have you looked at the official LinkedIN API? I haven’t in a long time, but surely they make recommendations readable.
Is it possible to retrieve a users profile or profile ID page by searching with their email address? If I have the email address of a user but want to obtain their full profile info, is that possible through their API?
Hi Brandon,
I am using PHP 5.3.5 and I get the following error when I run the code.
XML Parsing Error: junk after document element
Location: http://localhost/myfiles/
Line Number 2, Column 1:Deprecated: Function ereg() is deprecated in C:\xampp\htdocs\myfiles\linkedin.php on line 165
Please help.
Regards,
Abhinay
Hi Brandon,
I am using PHP 5.3.5 and I get the following error.
Only one top level element is allowed in an XML document. Error processing resource ‘http://localhost/myfiles/api.php'. Li…
Deprecated: Function ereg() is deprecated in C:\xampp\htdocs\myfiles\linkedin.php on …
Please help
Have you downloaded 1.6? I thought I addressed the ereg issue in that one.
Hi Brandon,
I used your latest version to grab my LinkedIn profile. And it worked absolutely fine. Now I want to grab my company profile from LinkedIn, Please help me to do this or may be you’ll do this great work for all other like you did earlier.
It’s pretty necessary for me to have my company profile fetched from LinkedIn without any authentications.
Any help or Idea will be highly appreciated.
Many Thanks
Mcekenzi
Hi Brandon,
I just downloaded v1.6, uploaded it as-is to my server, and it doesn’t start well: I get an error 500.
http://zebrana.net/libraries/phpLinkedin/
My server supports PHP 5.
Any help would be great as LinkedAPI gave me headaches
It’s OK I had just forgotten to enable the right permissions. Now I’m trying to figure out how to display the en-US version of my profile…