LinkedIn share callback Javascript SDK/API v2
Asked Answered
M

2

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'.

Mckelvey answered 28/1, 2019 at 11:6 Comment(10)
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?Osbert
@Osbert 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.Mckelvey
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.Osbert
@Osbert 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.Mckelvey
“Facebook still sends a callback after the user shared something” - only under very specific conditions AFAIK. developers.facebook.com/docs/sharing/reference/…Osbert
@Mckelvey linkedin social login suddenly stopped working for our product. Wondering that is relevant to your issue.Haldeman
@Osbert Facebook isn't really relevant for this question. The question is if it's possible with LinkedIn.Mckelvey
@Mckelvey 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!Pleiades
I'm afraid that it's not possible anymore.Shiller
@IslamElshobokshy I'm afraid it isn't possible either. But can you confirm? Or think of some work around?Mckelvey
S
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.

Stimulate answered 8/2, 2019 at 22:35 Comment(0)
M
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.

Martica answered 30/1, 2019 at 11:54 Comment(1)
How will it know when to trigger onsuccess? I don't think this is called when using a popup share.Mckelvey
S
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.

Stimulate answered 8/2, 2019 at 22:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.