Linkedin JS SDK分享成功但无法正常工作

时间:2018-05-10 21:35:01

标签: javascript api linkedin linkedin-jsapi

所以,我一直在搞乱Linkedin JS SDK的Share功能。

我已按照他们的示例(在Javascript SDK标签下):https://developer.linkedin.com/docs/share-on-linkedin

我设法对他们的API进行身份验证并发出POST请求,甚至设法获得响应,就像他们在文档中显示的那样(使用updateKey和updateUrl)。

但是Url不起作用,当我进入我的Linkedin帐户时,内容未被共享。

我可以多次发出相同的POST请求,总是得到一个成功的响应,并且没有任何共享。

任何人都可以帮我吗?

以下是代码:

<div id="share-with-linkedin"><i style="color: orange;" class="fa fa-linkedin-square fa-2x" aria-hidden="true"></i></div>

<script type="text/javascript">
// Handle the successful return from the API call
function onSuccess(data) {
  console.log(data);
}

// Handle an error response from the API call
function onError(error) {
  console.log(error);
}

// Use the API call wrapper to share content on LinkedIn
function shareContent() {
  // Build the JSON payload containing the content to be shared
  var payload = { 
    'comment': "OLHA A VAGAAAAA!",
    'content': {
      'title': "My Beautiful Title",
      'description': "My Awesome Description",
      'submitted-url': "https://www.99hunters.com",
      'submitted-image-url': "https://sep.yimg.com/ay/yhst-129804686222317/kiss-concert-poster-1970-5.gif"
    },
    'visibility': {
      'code': "anyone"
    }
  };

  IN.API.Raw("/people/~/shares?format=json")
    .method("POST")
    .body(JSON.stringify(payload))
    .result(onSuccess)
    .error(onError);
}

const linkedinBtn = document.getElementById("share-with-linkedin");
linkedinBtn.addEventListener("click", (event) => {
    shareContent();
});

示例成功回复:

{
   updateKey: "UPDATE-0-6400457564139581440",
   updateUrl: "https://www.linkedin.com/updates?discuss=&scope=0&stype=M&topic=6400457564139581440&type=U&a=WUeZ"
}

干杯, 马修斯。

0 个答案:

没有答案