如何验证LinkedIn的个人资料网址 [英] How to validate a LinkedIn public profile url
问题描述
我正在寻找一种验证链接的方法,以确保该链接指向PHP中的LinkedIn公开个人资料页面.
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.
我有一个网站,我希望我的用户能够在我的网站上的个人资料中共享他们的LinkedIn个人资料.
I have a website and I would like my users to be able to share their LinkedIn profile in their profile on my website.
推荐答案
尝试类似这样的操作,其中$username
是链接的用户名.
您还可以直接将$ profileurl设置为给定的链接,并使用以 http://www开头的str_pos
进行验证. .linkedin.com/in/
Try something like this where $username
is the linked-in username.
You also can set $profileurl directly to the link given and verify with str_pos
that is starts with 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
将是一个布尔值,指示配置文件是否有效.
$validprofile
will be a boolean indicating if the profile is valid.
这篇关于如何验证LinkedIn的个人资料网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!