Hello friends ajj me apko btaunga ki kis parkar ham javascript ka use karke login kar sakte hai.
Step 1- https://www.linkedin.com/developer/apps
Sabse pehle aap upper diye gye link se linkdin app create kar lijiye yanha apko kuch detail company name,app name etc fill karne hai
Step2-yanha website url me aap apne file ke path dale jese me is program ko localhost par run karwa raha hu uska website url is parkar hai
Example-http://localhost/linkdin/index.php/ or http://localhost/linkdin/
Aap in dono me se kisi be trah se apna website address enter karke apna linkdin app create kar sakte ho
Step3- app create hone ke bad apko yanha se ek api key milege jise hme niche diye gye code me sirf paste karke code ko save kar dena hai
Steps4- create a file index.html
Index.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:enter your api key here
authorize: true
onLoad: onLinkedInLoad
</script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></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);
}
function getProfileData() {
IN.API.Profile("me").fields("id", "first-name", "last-name", "public-profile-url", "email-address").result(displayProfileData).error(onError);
}
// Handle the successful return from the API call
function displayProfileData(post){
var user = post.values[0];
document.getElementById("first-name").innerHTML = user.firstName;
document.getElementById("last-name").innerHTML = user.lastName;
document.getElementById("email-address").innerHTML = user.emailAddress;
document.getElementById("public-profile-url").innerHTML = '<a href="'+user.publicProfileUrl+'" target="_blank">Visit profile</a>';
document.getElementById('profileData').style.display = 'block';
}
// Handle an error response from the API call
function onError(error) {
console.log(error);
}
// Destroy the session of linkedin
function logout(){
IN.User.logout(removeProfileData);
}
// Use the API call wrapper to request the member's basic profile data
// Remove profile data from page
function removeProfileData(){
document.getElementById('profileData').remove();
}
</script>
</head>
<body>
<script type="in/Login"></script>
<center>
<div id="profileData" style="display: none;">
<p><a href="javascript:void(0);" onClick="logout()">Logout</a></p>
<h1> firstname </h1> <p id="first-name"></p>
<h1>last name </h1> <p id="last-name"></p>
<h1> email id </h1> <p id="email-address"></p>
<h1> link </h1> <p id="public-profile-url"></p>
</div>
</div>
</div>
</center>
</body>
</html>
Yanha apko sirf apke dwara bnaye gye linkdin aap se milii api key enter karne hai
api_key: 81yra1eep4uvyw
head section me api key me apko apke dwara bnaye gye app se apko jo api key mli hai use yanha enter karna hai.or code ko save karna hai.
Is parkar aap easily 2 minutes me login with linkdin (javascript) ka option apne website me add kar sakte ho.
Thank You
Team Gajabwap Web In Hindi
2 comments
Click here for commentsbro but ache Post hai apki ye post but helpful rheere Lite I am fresher keep it up good work your blog is best
ReplyNice Post bro keep IT up
ReplyConversionConversion EmoticonEmoticon