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)
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 null@icorbin.com
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..