如何验证LinkedIn的个人资料网址 [英] How to validate a LinkedIn public profile url

查看:128
本文介绍了如何验证LinkedIn的个人资料网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种验证链接的方法,以确保该链接指向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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆