如何制作自定义linkedin共享按钮

时间:2012-05-23 04:41:06

标签: api share linkedin

我需要能够为自定义按钮添加共享功能。我对their generator不感兴趣,因为我无法在那里更改linkedin图像。我想将自己的图像用于linkedin share按钮。

10 个答案:

答案 0 :(得分:113)

官方LinkedIn API分享:

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

阅读使用条款!

使用“自定义网址”方法的示例链接:http://www.linkedin.com/shareArticle?mini=true&url=https://stackoverflow.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=stackoverflow.com

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

编辑:视频附在帖子上:

我检查过你无法在LinkedIn帖子中真正嵌入任何视频,唯一的选择就是将链接添加到带有视频的页面。

您可以通过将YT链接放入url param:

来实现

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

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

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

它与Vimeo完全相同,可能适用于任何网站。希望它会有所帮助。

编辑2:将图像拉到帖子:

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

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

尽管如此,它很有意思:

  

如果存在Open Graph标记,则LinkedIn的抓取工具不必   依靠它自己的分析来确定将共享哪些内容,   这提高了共享信息的可能性   正是你的意图。

它告诉我,即使没有附加Open Graph信息,LinkedIn也可以根据自己的分析提取这些数据。在YouTube的情况下似乎是这种情况,因为我找不到添加到YouTube页面的任何Open Graph标签。

答案 1 :(得分:44)

您可以使用LinkedIn ShareArticle网址创建自己的分享按钮,该网址可以包含以下参数:

https://www.linkedin.com/shareArticle?mini=true&url={articleUrl}&title={articleTitle}&summary={articleSummary}&source={articleSource}

您可以找到文档here,只需选择“自定义网址”即可查看详细信息。

答案 2 :(得分:25)

2020年7月-与LinkedIn进行社交共享

这里的许多答案直到最近才有效。目前, 受支持的参数为url,新的共享链接如下...

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

来源: Official Microsoft.com Linkedin Share Plugin Documentation 。开发人员文档的所有LinkedIn.com链接现在似乎都是空白页-可能与Microsoft对LinkedIn的收购有关。

从前,您可以使用以下参数:titlesummarysource。但是,如果您仔细阅读所有文档 实际上仍然有一种方法可以设置摘要,标题等! 在您要共享的页面的<head>块中...

  • <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将使用这些!来源:LinkedIn Developer Docs: Making Your Website Shareable on LinkedIn

不确定您所做的一切对吗?获取您要共享的页面的网址(例如,example.com,而不是linkedin.com/share?url=example.com),然后将该网址输入以下内容:LinkedIn Post Inspector。这将告诉您有关如何共享URL的所有信息!这还会拉出页面的当前缓存,然后刷新它(以防在LinkedIn数据库中页面的缓存版本卡住)。因为它会拉缓存,所以有时最好两次使用LinkedIn Post Inspector。

还不确定吗?这是我使用20多种社交共享服务构建的online demo。检查源代码,并亲自了解LinkedIn共享的工作原理。

自2012年以来,我一直在维护一个Github Repo,它一直在跟踪社交共享URL格式,请查看Github: Social Share URLs

为什么不加入所有社交共享网址?

Social Share URLs

答案 3 :(得分:6)

答案 4 :(得分:3)

LinkedIn最近修改了他们的网站,因此有大量旧链接只是重定向到开发人员支持主页。以下是LinkedIn支持网站相关页面的更新链接(截至2015年2月16日):https://developer.linkedin.com/docs/share-on-linkedin

答案 5 :(得分:2)

最好使用自定义网址方法。而且最简单。找到了这个。它将打开一个弹出窗口,您无需因为w_share等所有bs身份验证问题。

<a href="https://www.linkedin.com/shareArticle?mini=true&url=http://chillyfacts.com/create-linkedin-share-button-on-website-webpages&title=Create LinkedIn Share button on Website Webpages&summary=chillyfacts.com&source=Chillyfacts" onclick="window.open(this.href, 'mywin',
'left=20,top=20,width=500,height=500,toolbar=1,resizable=0'); return false;" ><img src="http://chillyfacts.com/wp-content/uploads/2017/06/LinkedIN.gif" alt="" width="54" height="20" /></a>

只需使用您自己的网址更改url。这是链接http://chillyfacts.com/create-linkedin-share-button-on-website-webpages/

答案 6 :(得分:1)

这对我有用:

https://www.linkedin.com/shareArticle?mini=true&url=articleUrl&title=YourarticleTitle&summary=YourarticleSummary&source=YourarticleSource

您可以将此链接替换为您的内容。它100%有效。

答案 7 :(得分:1)

该API现在已更新,以前的API将在2019年3月1日弃用。

要为LinkedIn创建自定义共享按钮,您需要立即进行POST呼叫。您可以阅读更新的文档here

答案 8 :(得分:1)

Linkedin已更新了他们的api,并且共享网址不再起作用。现在,您只能使用“ url”查询参数。其他任何参数都将由linkedin从网址中删除。

现在您被迫使用oAuth并与linkedin API进行交互以代表用户共享内容

答案 9 :(得分:0)

您可以在页面加载后自定义标准的Linkedin按钮:

$(".IN-widget span:first-of-type").css({
                'border': '2px solid #DCDCDC',
                '-webkit-border-radius': '3px',
                '-moz-border-radius': '3px',
                'border-radius': '3px'
                });
相关问题