Click here to Skip to main content
15,888,157 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I want to retrieve all public information of linkedin user for this I've used Javascript SDK something like this


F#
<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);
    }
    // 2. Runs when the Profile() API call returns successfully
    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

HTML
<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 + "";
}

}
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900