How to check the URL of a public LinkedIn profile

I am looking for a way to check a link to make sure it points to a LinkedIn general profile page in PHP.

I have a website and I would like my users to be able to share their LinkedIn profile in their profile on my website.

+8
php linkedin
source share
8 answers

Try something like this when $username is the associated username. You can also install $ profileurl directly on the specified link and check with str_pos , which starts at http://www.linkedin.com/in/

 $profileurl = "http://www.linkedin.com/in/".$username; $fp = curl_init($profileurl); $response = curl_exec($fp); $response_code = curl_getinfo($fp, CURLINFO_HTTP_CODE); $validprofile = ($response_code == 200); 

$validprofile will be a boolean indicating whether the profile is valid.

+4
source share

I found several ways a profile URL might look:

 http://uk.linkedin.com/pub/some-name/1/1b3/b45/ http://nl.linkedin.com/pub/other-name/11/223/544 http://www.linkedin.com/in/aname/ http://www.linkedin.com/in/another-name http://linkedin.com/in/name http://nl.linkedin.com/in/name http://nl.linkedin.com/in/name/ 

I used this regex to describe it:

 ^https?://((www|\w\w)\.)?linkedin.com/((in/[^/]+/?)|(pub/[^/]+/((\w|\d)+/?){3}))$ 

It’s not strict, but he got me home.

change
- Added https support

+5
source share

There are very nice examples on the pages of the developer API http://developer.linkedin.com/

This http://developer.linkedin.com/plugins/member-profile-plugin may be what you are looking for.

+3
source share

I use another regular expression more believable:

^(http(s)?:\/\/)?([\w]+\.)?linkedin\.com\/(pub|in|profile)

It includes non-scrim URLs and all samples from other answers. Here you can make any changes http://regex101.com/r/vE8tV7

+3
source share

The following expression will help you with all the patterns:

 ((https?:\/\/)?((www|\w\w)\.)?linkedin\.com\/)((([\w]{2,3})?)|([^\/]+\/(([\w|\d-&#?=])+\/?){1,}))$ 

Demo

https://regex101.com/r/oT7iM2/5

+3
source share

This is a validated regular expression that I use on my website. I fit all the options that currently exist.

 var linkedin=/(https?)?:?(\/\/)?(([w]{3}||\w\w)\.)?linkedin.com(\w+:{0,1}\w*@)?(\S+)(:([0-9])+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/; 
+2
source share

Use a regular expression to ensure that the link matches the form obtained in the associated common profiles.

0
source share

I just used the following regex:

 http(s)?:\/\/([w]{3}\.)?linkedin\.com\/in\/([a-zA-Z0-9-]{5,30})\/? 

According to the latest version of a Linkedin document, a user profile can have 5-30 letters or numbers.

It works for the following URL list:

 https://www.linkedin.com/in/your-profile-5-30-length/ https://linkedin.com/in/your-profile-5-30-length/ http://www.linkedin.com/in/your-profile-5-30-length/ http://linkedin.com/in/your-profile-5-30-length/ 
0
source share

All Articles