使用JS givs错误“消息”获取LinkedIn数据:“未知身份验证方案”

时间:2018-10-10 08:42:16

标签: linkedin linkedin-api

我遵循了这个示例https://www.c-sharpcorner.com/blogs/fetch-linkedin-data-using-javascript,从特定于公司的公司获取数据(例如更新/发布)。

我收到以下错误。

{   “ errorCode”:0,   “ message”:“未知身份验证方案”,   “ requestId”:“ MXRLWYPBNU”,   “状态”:401,   “时间戳记”:1539160527230 }

该公司已将我的个人资料添加为公司管理员,因此我应该具有身份验证才能获取数据。

我做错了什么?     好了,这是我的代码:`

<script type="text/javascript" src="https://platform.linkedin.com/in.js">
api_key: 8616po0krrhh2k
scope: r_basicprofile r_emailaddress
onLoad: onLinkedInLoad,
</script>


$(document).ajaxSend(function (event, jqxhr, settings) {
if (settings.url == "https://www.linkedin.com/uas/oauth/authenticate") {
    settings.url = "https://www.linkedin.com/uas/oauth/authorize"
}});

function onLinkedInLoad() {
IN.Event.on(IN, "auth", onLinkedInAuth());}

function onSuccess(data) {
console.log(data); }


function onError(error) {
console.log(error);
}
function onLinkedInAuth() {
var cpnyID = 86104; //the Company ID for which we want updates
IN.API.Raw("/companies/" + cpnyID + "/updates?event-type=status- 
update&start=0&count=10&format=json").result(displayCompanyUpdates);

console.log("After auth");
}

function displayCompanyUpdates(result) {
var div = document.getElementById("displayUpdates");
var el = "<ul>";
var resValues = result.values[0];
for (var i in resValues) {
var share = resValues[i].updateContent.companyStatusUpdate.share;
    var isContent = share.content;
    var isTitled = isContent,
        isLinked = isContent,
        isDescription = isContent,
        isThumbnail = isContent,
        isComment = isContent;
    if (isTitled) {
        var title = isContent.title;
    } else {
        var title = "News headline";
    }
    var comment = share.comment;
    if (isLinked) {
        var link = isContent.shortenedUrl;
    } else {
        var link = "#";
    }
    if (isDescription) {
        var description = isContent.description;
    } else {
        var description = "No description";
    }

    if (share) {
    var content = "< a target = '_blank' href = " + link + " > " + comment + " 
    </a><br>";

     el += "<li><div>" + content + "</div></li>";
    }
    console.log(share);
}
 el += "</ul>";
 document.getElementById("displayUpdates").innerHTML = el;
}




<div id="displayUpdates"></div>`

1 个答案:

答案 0 :(得分:0)

我在代码中看到的一个明显问题是,您为要进行的调用添加了错误的作用域。

对于公司API调用,您需要以下范围:rw_company_admin