Linkedin JS SDK Share responding with success but

2019-08-02 10:51发布

So, I've been messing around with the Share function of the Linkedin's JS SDK.

I've followed their example (under Javascript SDK tab): https://developer.linkedin.com/docs/share-on-linkedin

I've managed to authenticate and make the POST request to their API, and even managed to get a response just like what they show in the docs (with updateKey and updateUrl).

But the Url doesn't work, and when I go to my Linkedin account, the content wasn't shared.

I'm able to make the same POST request several times, always getting a successful response, and nothing is ever shared.

Can anyone help me with this?

Here's the code:

<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();
});

And a sample successful response:

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

Cheers, Matheus.

0条回答
登录 后发表回答