I want to retrieve all public information of linkedin user for this I've used Javascript SDK something like this
<script type="text/javascript" src="https://platform.linkedin.com/in.js">
api_key: 'my key'
onLoad: onLinkedInLoad
authorize: true
</script>
<script type="text/javascript">
function onLinkedInLoad() {
IN.Event.on(IN, "auth", onLinkedInAuth);
}
function onLinkedInAuth() {
IN.API.Profile("me").fields("id", "first-name", "last-name", "email-address"
, "public-profile-url", "picture-url", "picture-urls::(original)", "headline", "summary", "location", "industry", "positions").result(displayProfiles);
}
function displayProfiles(profiles) {
member = profiles.values[0];
document.getElementById("profiles").innerHTML =
"<p>" + member.id + "<br> " + member.firstName + "<br> " + member.lastName + "<br>" + member.emailAddress + "</p>"
+ "<br>" + member.industry + "</p>"
+ "<br>" + member.summary + "</p>";
var positions = profiles.values[0].positions;
var positionCount = positions._total;
for(var i = 0; i < positionCount; i++) {
var company = positions.values[i].company;
var title = positions.values[i].title;
document.getElementById("profiles").innerHTML += "<div >" + title + ", " + company.name + "</div>";
}
}
</script>
and in my body tag I've
<body>
<script type="in/Login"></script>
<div id="profiles"></div>
</body>
It works fine as user now have to provide its credentials and I've saved all this information into my local DB.
Now what I want is to retrieve data of same user after some time without user authentication, I just have to update my DB with user latest information from Linkedin. Since user have allowed access my site to get his profile, therefore I don't want user to bother again.I just wanted to update user info of my local DB without letting user know about it but only if user have allowed its access to me.
What I have tried:
function onLinkedInLoad() {
IN.Event.on(IN, "auth", onLinkedInAuth);
}
function onLinkedInAuth() {
IN.API.Profile("me").fields("id", "first-name", "last-name", "email-address"
, "public-profile-url", "picture-url", "picture-urls::(original)", "headline", "summary", "location", "industry", "positions").result(displayProfiles);
}
// 2. Runs when the Profile() API call returns successfully
function displayProfiles(profiles) {
member = profiles.values[0];
document.getElementById("profiles").innerHTML =
"" + member.id + " " + member.firstName + " " + member.lastName + "" + member.emailAddress + ""
+ "" + member.industry + ""
+ "" + member.summary + "";
var positions = profiles.values[0].positions;
var positionCount = positions._total;
for(var i = 0; i " + title + ", " + company.name + "";
}
}