gpt4 book ai didi

javascript - 从 Linkedin api 获取公司名称

转载 作者:行者123 更新时间:2023-11-28 13:29:46 24 4
gpt4 key购买 nike

我正在尝试从特定的 url 和 ID 获取公司名称。因此,我需要找到某人当前所在的公司并展示该信息。到目前为止,这是我的代码:

> <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>

我遇到的问题是我只获取基本的成员(member)数据并尝试使用另一个网址获取公司名称,但该网址不起作用..

最佳答案

好吧,我是这样解决的:

    <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>

关于javascript - 从 Linkedin api 获取公司名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25991863/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com