领英api-获取公司更新



我正在尝试使用领英的api获取公司更新。不知怎么的,我无法让它发挥作用。我可以看到console.log("On-auth");在控制台中,但之后什么也没发生。就好像它停止了那个函数。。。没有可见的错误,没有其他控制台消息。有人知道可能出了什么问题吗?

我使用的是领英的测试公司,它不需要任何管理权限。

我的代码是:

<head>
    <script type="text/javascript" src="https://platform.linkedin.com/in.js">
    api_key: 14characters
    onLoad: onLinkedInLoad 
    authorize: true 
    </script>
</head>
<body>
    <div id="displayUpdates"></div>
    <script type="text/javascript">
        function onLinkedInLoad() {
            IN.Event.on(IN, "auth", onLinkedInAuth);
            console.log("On auth");
        }
        function onLinkedInAuth() {
            var cpnyID = 2414183; //LinkedIn's testDevCo
            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;
            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;
                if (isTitled) {
                    var title = isContent.title;
                } else {
                    var title = "News headline";
                }
                if (isLinked) {
                    var link = isContent.shortenedUrl;
                } else {
                    var link = "#";
                }
                if (isDescription) {
                    var description = isContent.description;
                } else {
                    var description = "No description";
                }
                if (isThumbnailz) {
                    var thumbnailUrl = isContent.thumbnailUrl;
                } else {
                    var thumbnailUrl = "http://placehold.it/60x60";
                }
                if (share) {
                    var content = "<a target='_blank' href=" + link + ">" + title + "</a><br>" + description;
                    el += "<li><img src='" + thumbnailUrl + "' alt=''>" + content + "</li>";
                }
                console.log(share);
            }
            el += "</ul>";
            div.innerHTML = el;
        }
        </script>
</body> 

我最终在头上有了这个-将onLinkedInAuth添加到onLoad:

<script type="text/javascript" src="https://platform.linkedin.com/in.js">
    api_key: 14characters
    onLoad: onLinkedInLoad, onLinkedInAuth 
    authorize: true 
</script>

成功了。

最新更新