1

I am trying create share button for sharing via Linkedin include title and description

I figured out that it possible to do via Custom URL, like that: https://www.linkedin.com/shareArticle?mini=true&url=http://developer.linkedin.com&title=LinkedIn%20Developer%20Network&summary=My%20favorite%20developer%20program&source=LinkedIn

Request parameters: enter image description here

if i try make it for my cause, it share only link not title and description:

https://www.linkedin.com/shareArticle?mini=true&url=https://www.athenatools.com/&title=ATHENA%20TOOLS&summary=THAT%20IS%20MY%20EXAMPLE&source=athenatools

Info i take from here: https://developer.linkedin.com/docs/share-on-linkedin

In conclusion, my question is how to make sharing include title, description and link at the site which i want

Max
  • 781
  • 7
  • 19

2 Answers2

1

Your url and some of the parameters need to be urlencoded, so for example the url parameter should look like that: https%3A%2F%2Fathenatools.com%2F

You can use this tool: https://www.url-encode-decode.com/

Marcin
  • 1,488
  • 1
  • 13
  • 27
  • 1
    Or instead of using an online converter, do it on the fly when building the URL, either in Javascript using [`encodeURI()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURI), or on the server when generating the page, using a similar function supported by your server scripting language. – GolezTrol Feb 11 '19 at 12:03
  • https://www.linkedin.com/shareArticle?mini=true&url=https%3A%2F%2Fwww.athenatools.com%2F&title=ATHENA+TOOLS&summary=THAT+IS+MY+EXAMPLE&source=athenatools I made it, but get only link, without title and description – Max Feb 11 '19 at 12:09
  • I am also looking for the same solution, how can we send custom parameters to posts being shared other than Meta tags? when pages are client rendered. – Shriram Aug 04 '23 at 17:16
0

As stated by Marcin, you must do URL encoding when passing one URL as a parameter to another URL's GET parameters (not just at LinkedIn URLs, but with all URLs). But there's actually still a bit more here to solve!

You seem to be using an old format of the LinkedIn share API. Since being acquired by Microsoft, much of LinkedIn's documentation (especially the up-to-date stuff) can be found on the Microsoft developer sites. Take a look: Official Microsoft LinkedIn Sharing Documentation. So, your URL should look like...

https://www.linkedin.com/sharing/share-offsite/?url={url}

You are trying to also send a title and other parameters, but the only supported parameter is url.

You probably want to share title, etc., information, though, right? In that case, set the og: tags in the <head> block of your HTML page, like so...

  • <meta property='og:title' content='Title of the article"/>
  • <meta property='og:image' content='//media.example.com/ 1234567.jpg"/>
  • <meta property='og:description' content='Description that will show in the preview"/>
  • <meta property='og:url' content='//www.example.com/URL of the article" />

Source: LinkedIn Documentation: Making Your Website Shareable on LinkedIn.

og: tags really are a good-standards practice, so why not? If you want to know that you set up everything correctly, LinkedIn has you covered there, too:

LinkedIn Post Inspector : Check the URL you are trying to share to make sure everything is properly configured, with the right og: tags, etc.. Input the URL you are sharing, i.e., example.com/YourSite/ThisPageIsWhatYouWantToBeSharedOnLinkedIn.

Hope this helps!

HoldOffHunger
  • 18,769
  • 10
  • 104
  • 133
  • Is there any other way around than using meta tags. I have to use share in multiple pages. My project is client side rendering. so wont be able to change meta tags every time. In whatsapp we were able to send the url along with the text. Looking for a solution like that. – vinoth Jul 27 '22 at 10:56