简体   繁体   中英

Get company name from Linkedin api

Im trying to get the company name from a specific url and ID. So, I need to get the company someone is currently at and displaying that. Here's my code so far:

> <script type="text/javascript">   function OnLinkedInFrameworkLoad() { 
> IN.Event.on(IN, "auth", OnLinkedInAuth); }
> 
>   function OnLinkedInAuth() {
>     IN.API.Profile("me").result(ShowProfileData);
>     IN.API.Raw("/people/~/picture-urls::(original)").result(highRes); }
> 
>     function highRes(images) {
>       var img = images.values[0];
>       $('#user').append('<img src="' + img + '">');
>     }
> 
>   function ShowProfileData(profiles) {
>     var member = profiles.values[0];
>     var id=member.id;
>     var firstName=member.firstName; 
>     var lastName=member.lastName; 
>     var imgSrc=member.pictureUrl; 
>     var headline=member.headline;
> 
>     var url = "http://api.linkedin.com/v1/people/" + id + "/picture-url";
>     console.log(member)
>     console.log(url)
>     console.log(company)
>     //use information captured above
> 
>     $("p").append("You are logged in as: ")
>     $('#firstName').append(firstName);
>     $('#lastName').append(lastName);
>     $('#company').append(company);
> 
>     var url_2 = "http://api.linkedin.com/v1/people/" + id + "~:(positions:(is-current,company:(name)))";
>     console.log(url_2);
>     } </script>

The trouble I have is that I only get the basic member data and trying to fetch the company name with another url but the url is not working..

Ok, I solved it like this:

    <script type="text/javascript">

    function OnLinkedInFrameworkLoad() {
    IN.Event.on(IN, "auth", OnLinkedInAuth);
    // Use a larger login icon.
    $('a[id*=li_ui_li_gen_]').html('<img src="images/linkButton.png" height="40" width="130" border="0" class="linkButton" />');}

    function OnLinkedInAuth() {
    IN.API.Profile("me").fields(["firstName","headline","positions:(is-current,company:(name))"])
    .result(function(result) {
       var firstName = result.values[0].firstName;
       var company = result.values[0].positions.values[0].company.name;
       $('#firstName').append(firstName);
       $('#company').append(company);
    })
    IN.API.Raw("/people/~/picture-urls::(original)").result(highRes);
}

    function highRes(images) {
      var img = images.values[0];
      $('.linkedin').append('<img src="' + img + '" class="profile">');
      $('.mobile-linkedin').append('<img src="' + img + '"class="profile">');
      $("#guest").hide();
      $("#hide").hide();
    }

    function ShowProfileData(profiles) {
    var member = profiles.values[0];
    var id=member.id;
    var firstName=member.firstName;

    var url = "http://api.linkedin.com/v1/people/" + id + "/picture-url";
    //use information captured above
    }
    </script>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM