且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何制作自定义的 LinkedIn 分享按钮

更新时间:2023-12-04 22:51:10

用于分享的官方 LinkedIn API:

Official LinkedIn API for sharing:

https://developer.linkedin.com/docs/share-on-linkedin

阅读使用条款!

使用自定义 URL"的示例链接方法:http://www.linkedin.com/shareArticle?mini=true&url=https://***.com/questions/10713542/how-to-make-custom-linkedin-share-button/10737122&title=How%20to%20make%20custom%20linkedin%20share%20button&summary=some%20summary%20if%20you%20want&source=***.com

Example link using "Customized URL" method: http://www.linkedin.com/shareArticle?mini=true&url=https://***.com/questions/10713542/how-to-make-custom-linkedin-share-button/10737122&title=How%20to%20make%20custom%20linkedin%20share%20button&summary=some%20summary%20if%20you%20want&source=***.com

您只需要使用 JavaScript 在弹出窗口中打开它或将其加载到 iframe.简单而有效 - 这就是我想要的!

You just need to open it in popup using JavaScript or load it to iframe. Simple and works - that's what I was looking for!

我检查过您无法在 LinkedIn 帖子中真正嵌入任何视频,唯一的选择是将链接添加到包含视频本身的页面.

I checked that you can't really embed any video to LinkedIn post, the only option is to add the link to the page with video itself.

您可以通过将 YT 链接放入 url 参数来实现:

You can achieve it by putting YT link into url param:

https://www.linkedin.com/shareArticle?mini=true&url=https://www.***.com/watch?v=SBi92AOSW2E

如果您指定 summarytitle 那么LinkedIn 将停止从视频中提取它,例如:

If you specify summary and title then LinkedIn will stop pulling it from the video, e.g.:

https://www.linkedin.com/shareArticle?mini=true&summary=***&title=f1&url=https://www.***.com/watch?v=SBi92AOSW2E

它与 Vimeo 的工作方式完全相同,并且可能适用于任何网站.希望它会有所帮助.

It does work exactly the same with Vimeo, and probably will work for any website. Hope it will help.

当您打开上面的链接时,您会看到 LinkedIn 加载了一些图片以及传递的 URL(以及可选的标题和摘要).

When you open above links you will see that LinkedIn loads some images along with the passed URL (and optionally title and summary).

LinkedIn 会自动执行此操作,您可以在此处阅读相关信息:https://developer.linkedin.com/docs/share-on-linkedin#opengraph

LinkedIn does it automatically, and you can read about it here: https://developer.linkedin.com/docs/share-on-linkedin#opengraph

虽然它说的很有趣:

如果存在 Open Graph 标签,LinkedIn 的爬虫将不必依靠它自己的分析来确定将共享哪些内容,这提高了共享信息的可能性正是您想要的.

If Open Graph tags are present, LinkedIn's crawler will not have to rely on it's own analysis to determine what content will be shared, which improves the likelihood that the information that is shared is exactly what you intended.

它告诉我,即使没有附加 Open Graph 信息,LinkedIn 也可以根据自己的分析提取这些数据.就 *** 而言,情况似乎确实如此,因为我找不到任何添加到 *** 页面的 Open Graph 标签.

It tells me that even if Open Graph information is not attached, LinkedIn can pull this data based on its own analysis. And in case of *** it seems to be the case, as I couldn't find any Open Graph tags added to *** pages.