LinkedIn share callback Javascript SDK/API v2

I am trying to share content through the LinkedIn JavaScript SDK. But LinkedIn just updated their API and I cannot figure out how to: share a URL inside a popup and get a callback on a successful share.

With the old LinkedIn share plugin you had something like this:

https://docs.microsoft.com/en-us/linkedin/consumer/integrations/self-serve/plugins/share-plugin

<script src="//platform.linkedin.com/in.js" type="text/javascript">lang: en_US</script>
<script type="IN/Share" data-url="https://www.linkedin.com"></script>

But it had an on-success attribute (this doesn't work anymore).

I also thought of some work around like checking if there is a +1 to the share counter. But the counter is also deprecated. Another workaround could be checking when the share popup closes. But then the user can just close it, and they shared 'successfully'.

Answers:

Answer

You were sharing content using Share with LinkedIn feature (which supported the on-success callback) of JavaScript SDK which is going to be deprecated according to linked-in's developer-program-updates.

Our JavaScript and Mobile Software Development Kits (SDKs) will stop working. Developers will need to migrate to using OAuth 2.0 directly from their apps.

Here it instructs developers to migrate to OAuth 2.0 but you are looking into the share plugin which provides only basic URL sharing functionality only. If you look into the docs you can see the response section contains 201 Created status code on success and also includes ID of the newly created post.

Answer

So when you are using API, every time when someone clicks the share button API return value,

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

If someone will share your content data will be some value, but if someone click it and close it just after that data value will be null. You can check it using code above.

I hope that will help you.

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.