我正在阅读文档,但对我来说不是很清楚。
我想构建一个按钮,登录的用户可以单击该按钮,重定向到linkedin,以便我可以读取其个人资料,然后再获取此信息。
这可能吗?
我正在使用Vue + Laravel
答案 0 :(得分:2)
简短的回答-是的。就像您可以使用Google,Twitter,Facebook等登录的方式一样(该方式可以使您一定程度地访问某人的个人资料信息),您也可以通过oAuth获取某人的LinkedIn信息。
LinkedIn文档在这里:https://docs.microsoft.com/en-us/linkedin/shared/authentication/authorization-code-flow?context=linkedin/context 这里是使用Laravel的示例:https://codebriefly.com/laravel-socialite-linkedin-login-part-2/
简而言之,您需要:
答案 1 :(得分:0)
使用javascript:https://makitweb.com/how-to-login-linkedin-with-javascript-api/#createapp
<!doctype html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script type="text/javascript" src="//platform.linkedin.com/in.js">
api_key: 81n4hu3u7jybix
authorize: true
onLoad: onLinkedInLoad
</script>
<script type="text/javascript">
// Setup an event listener to make an API call once auth is complete
function onLinkedInLoad() {
IN.Event.on(IN, "auth", getProfileData);
}
// Logout user
function logout(){
IN.User.logout(onLogout);
}
function onLogout(){
console.log('Logout successfully');
}
// Use the API call wrapper to request the member's basic profile data
function getProfileData() {
IN.API.Profile("me").fields("first-name", "last-name", "email-address","picture-url").result(function (data) {
var userdata = data.values[0];
$.ajax({
url: "saveuser.php",
type: "post",
data: {"social_type": "linkedin","fname": userdata.firstName,"lname": userdata.lastName,"email": userdata.emailAddress, "profile_image": userdata.pictureUrl },
success: function(response){
$('#tableUser').css('display','block');
$('#fullname').text( userdata.firstName + " " + userdata.lastName);
$('#email').text( userdata.emailAddress );
$('#profile_photo').attr( 'src',userdata.pictureUrl );
logout();
}
});
}).error(function (data) {
console.log(data);
});
}
</script>
</head>
<body>
<!-- LinkedIn signin button -->
<script type="in/Login"></script>
<table id='tableUser' style='display: none;'>
<tr>
<td>Name</td>
<td><span id='fullname'></span></td>
</tr>
<tr>
<td>Email</td>
<td><span id='email'></span></td>
</tr>
<tr>
<td>Profile image</td>
<td><img src='' width='32' height='32' id='profile_photo'></td>
</tr>
</table>
</body>
</html>