领英分享 Post URL

LinkedIn Share Post URL

我有一个应用程序可以让人们 post 将内容添加到他们的 LinkedIn 页面。我想要做的是创建一个按钮,我可以将其包含在电子邮件中,单击该按钮会将用户发送到 LinkedIn 并打开框以共享 post。我想知道的是如何生成这个 url。结构是什么样的?到目前为止,我找到的所有信息都是关于如何将 link 分享到 LinkedIn 上的另一个网站,而不是如何将用户引导至分享 post 框。

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

来自 LinkedIn developer docs("Customized URL" 选项卡):

https://www.linkedin.com/shareArticle?mini=true&url=http://developer.linkedin.com&title=LinkedIn%20Developer%20Network&summary=My%20favorite%20developer%20program&source=LinkedIn

第一步,让我们看看URL是对的...

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。当然,不要相信我们的话!以上任何 URL 格式都将重定向到 2020 URL 格式。

第二步,`summary`,`title`之类的东西怎么用?

在 HTML 的 <head> 块中使用 og: 标签!引用文档,这些应该看起来像...

  • <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' />

来源:LinkedIn Share Documentation: Making Your Website Shareable on LinkedIn

第三步,现在要检查一下你做对了吗?

这是最简单的部分!取你分享的URL(即example.com,不是linkedin.com?share=example.com),输入LinkedIn Post Inspector。您将被告知决定您的网页在 LinkedIn 上的共享方式的所有信息,从 og: 标签到 oEmbed 数据。

这是一个 online demo 分享 link 到 20 多个服务。查看源代码,您可以亲眼看到 Linkedin 的分享 link 是如何工作的!

第四步,为什么`og:description`标签不起作用?

我有一个more detailed answer elsewhere on the og:description tag not displaying in the LinkedIn preview.

如果您对定期维护的 GitHub 项目感兴趣,该项目会跟踪此信息,因此您不必关注,请查看!我是贡献者! Social Share URLs

LinkedIn 共享有问题并找到了解决方法:

与非 SSL (http) 地址共享的站点将显示错误:“出了点问题 - 再试一次”

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

如何修复“出现问题”共享 link 错误:

修改开头的 {url} - 将 http 替换为 https:

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

访问 link 以生成 LinkedIn 的缩略图和页面描述。

非 SSL (http) 和 SSL (https) 的共享 link 地址现在可以正常工作。

编辑:将 //example.com 替换为您的网站