How to validate a LinkedIn public profile url

后端 未结 9 2924
迷失自我
迷失自我 2021-02-20 16:43

I am looking for a way to validate a link to make sure that it is pointing to a LinkedIn public profile page in PHP.

I have a website and I would like my users to be abl

9条回答
  •  夕颜
    夕颜 (楼主)
    2021-02-20 16:51

    I've found a number of ways the profile url can look like:

    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've used this regex to describe it:

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

    It is not strict-strict but it got me home.

    edit
    - Added https support

提交回复
热议问题