14

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://learn.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'.

Tygo
  • 196
  • 3
  • 29
  • What do you need such a callback for in the first place? Those plugins usually give the user feedback directly if anything went wrong. Are you trying to _force_ people to share something? – 04FS Jan 28 '19 at 11:11
  • @04FS there should be a script called after a user _willingly_ shares one of my pages. But this script should only be called when the user actually shared. – Tygo Jan 28 '19 at 11:14
  • I guess they are probably following the example of other platforms like Facebook, who deliberately removed this, because it was abused to force people to share, and therefor created mostly spam. – 04FS Jan 28 '19 at 11:18
  • @04FS Facebook still sends a callback after the user shared something. They just added in their privacy statement that you are not allowed to force people to share. The user should share by themselves. – Tygo Jan 28 '19 at 11:42
  • _“Facebook still sends a callback after the user shared something”_ - only under very specific conditions AFAIK. https://developers.facebook.com/docs/sharing/reference/share-dialog#response – 04FS Jan 28 '19 at 11:47
  • 1
    @Tygo linkedin social login suddenly stopped working for our product. Wondering that is relevant to your issue. – chamoda Jan 28 '19 at 12:08
  • @04FS Facebook isn't really relevant for this question. The question is if it's possible with LinkedIn. – Tygo Jan 28 '19 at 12:43
  • 1
    @Tygo I work for a social sharing company that creates share buttons for networks (including LinkedIn). As far as we know, none of them have a confirmation that something actually got shared or not. You can only provide the means to open the share window and hope that the user follows through with the share. If somebody can show me otherwise (that there is a share confirmation), please let me know! – Naltroc Jan 29 '19 at 20:33
  • I'm afraid that it's not possible anymore. – Alexandre Elshobokshy Jan 30 '19 at 13:08
  • @IslamElshobokshy I'm afraid it isn't possible either. But can you confirm? Or think of some work around? – Tygo Jan 30 '19 at 14:35

2 Answers2

1

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.

Tygo
  • 196
  • 3
  • 29
Piotr Mirosz
  • 846
  • 9
  • 20
  • 3
    How will it know when to trigger onsuccess? I don't think this is called when using a popup share. – Tygo Jan 30 '19 at 12:00
1

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.

Munim Munna
  • 17,178
  • 6
  • 29
  • 58