87

I have an app that lets people post content to their LinkedIn page. What I want to do is create a button that I can include in an email that when clicked, will send the user to LinkedIn and open the box to share a post. What I would like to know is how to generate this url. What is the structure like? All the information I've found so far is about how to share a link to another website on LinkedIn, not how to direct a user to the share post box.

Example link: https://www.linkedin.com/share?id=0123456789

linkedin

0

4 Answers 4

182

First step, let's see what URL is right...

2010:

https://www.linkedin.com/cws/share?url={url}

2015:

https://www.linkedin.com/shareArticle?url={url}&title={title}&summary={text}&source={provider}

2020:

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

Official Microsoft LinkedIn Share API Documentation. Of course, don't take our word for it! Any of the above URL formats will redirect to the 2020 URL format.

Second step, just how do you use things like `summary`, `title`, etc.?

Use og: tags in the <head> block of your HTML! To quote the documentation, these should look like...

  • <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 Share Documentation: Making Your Website Shareable on LinkedIn

Third step, now want to check to see you did everything right?

That's the easy part! Take the URL you are sharing (i.e., example.com, not linkedin.com?share=example.com), and input it into the LinkedIn Post Inspector. You will be told everything that goes into determining how your webpage is shared on LinkedIn, from og: tags to oEmbed data.

Here's an online demo with share links to 20+ services. Check the source code and you can see first-hand how the share link for Linkedin works!

Fourth step, why doesn't the `og:description` tag work?

I have a more detailed answer elsewhere on the og:description tag not displaying in the LinkedIn preview.

If you are interested in a regularly maintained GitHub project that keeps track of this so you don't have to, check it out! I'm a contributor! Social Share URLs

Social Share URLs Image

3
  • 2
    Thank you for sharing the Social Share URLs repository!
    – Nesk
    May 29, 2020 at 12:13
  • 1
    The repository is really great. It is like a dream for new bloggers. Jul 25, 2020 at 19:22
  • For anyone having a weird console error on linkedin when using the URL, this can happen if the share URL is not correctly encoded (e.g. not wrapped in encodeURIComponent())
    – Fran Cano
    Jan 13, 2021 at 11:07
61

From the LinkedIn developer docs ("Customized URL" tab):

https://www.linkedin.com/shareArticle?mini=true&url=http://developer.linkedin.com&title=LinkedIn%20Developer%20Network&summary=My%20favorite%20developer%20program&source=LinkedIn
8
  • 4
    May be its old thread but can you help me with title and summary. It is not picking up title and summary for posts. Aug 8, 2018 at 19:06
  • 5
    Docs are updated with new API: learn.microsoft.com/en-us/linkedin/consumer/integrations/… Feb 18, 2019 at 15:29
  • 4
    You can also use https://www.linkedin.com/sharing/share-offsite/?url=...
    – Sebastien
    May 24, 2019 at 15:55
  • 5
    The URL parameters no longer work, LinkedIn has removed them Sep 20, 2019 at 1:14
  • 2
    linkedIn share with url does not working for me. Do you know any other way to do this?
    – Priya jain
    Nov 26, 2019 at 10:30
9

Had issues with LinkedIn Sharing and found a resolve:

Sites shared with Non-SSL (http) addresses will display the error: "Something went wrong - Try again"

https://www.linkedin.com/sharing/share-offsite/?url=http://example.com

How to fix the "Something went wrong" share link error:

Modify the beginning the {url} - replacing the http with https:

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

Visit the link to generate LinkedIn's thumbnail and page description.

Both share link addresses for Non-SSL (http) and SSL (https) will work correctly now.

Edit: Replace //example.com with your website

6
  • 1
    That's incorrect. example.com is always an invalid, test-domain. I'm not seeing "thumbnail and page description" for example.com, probably because it doesn't exist. And this works fine without error and it's HTTP-only: linkedin.com/sharing/share-offsite/?url=http://google.com Feb 16, 2021 at 12:48
  • 1
    That's because example.com is an example. You need to replace it with a real URL but the information I provide still stands. Your Google link isn't a good example because it would have the thumbnail and page description already generated. This is specifically addressing a concern I've seen mentioned in multiple places for developers with new websites that are recently built but cannot get the LinkedIn Share to work. Feb 19, 2021 at 0:51
  • Right, example.com doesn't work, but google.com does work. What makes you think "Your google link isn't a good example", when it works, and when your link does not? Feb 19, 2021 at 4:09
  • Because Google has already been crawled by LinkedIn. Forget example.com - it's a placeholder for 'yourwebsite.xyz'. When a website is initially created - LinkedIn will only crawl a https version of the site. What I'm saying is - a developer who hasn't enabled SSL will encounter this problem. You can recreate this by creating a brand new website and domain that has never been shared in LinkedIn. Don't enable SSL and try to share it via LinkedIn. It will cause an error "Something went wrong - Try again" Feb 19, 2021 at 4:51
  • 1
    Not seeing that problem. I've never shared holdoffhunger.com on linkedin, and it works fine with http-only: linkedin.com/sharing/share-offsite/?url=http://… Feb 19, 2021 at 14:12
3

I found a new way on 2023 to do this:

https://www.linkedin.com/feed/?shareActive=true&text=This is my text! https://ogp.me/ %23NewPost
3
  • Can we have the option to add Image, Mention In Text, and URL. Please add a documentation link if you have I am not able figure it out. Nov 2 at 11:18
  • "linkedin.com/feed/?shareActive=true" this is working fine, but its not opening recent draft. how to do that? Nov 13 at 11:30
  • @FerozHussain it will open only a new post creater modal only. Check a authorization API may be it will help you Nov 16 at 3:40

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.