Javascript 如何创建一个简单的分享linkedIn链接?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/29744036/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to create a simple share linkedIn link?
提问by rob.m
I am using the followings for twitter, facebook and google+ but the linkedin gives me an error dialog box:
我在 twitter、facebook 和 google+ 上使用以下内容,但linkedin 给了我一个错误对话框:
<a class="btn btn-default icon" href="javascript:void(0)" onclick="window.open( 'http://www.twitter.com/share?url=<?php the_permalink(); ?>', 'sharer', 'toolbar=0, status=0, width=626, height=436');return false;" title="Share on Twitter"><span class="character">a</span></a>
<a class="btn btn-default icon" href="javascript:void(0)" onclick="window.open( 'http://www.facebook.com/sharer.php?u=<?php the_permalink(); ?>', 'sharer', 'toolbar=0, status=0, width=626, height=436');return false;" title="Share on Facebook"><span class="character">b</span></a>
<a class="btn btn-default icon" href="javascript:void(0)" onclick="window.open( 'https://plus.google.com/share?url=<?php the_permalink(); ?>', 'sharer', 'toolbar=0, status=0, width=626, height=436');return false;" title="Share on Google+"><span class="character">c</span></a>
<a class="btn btn-default icon" href="javascript:void(0)" onclick="window.open( 'https://www.linkedin.com/share?url=<?php the_permalink(); ?>', 'sharer', 'toolbar=0, status=0, width=626, height=436');return false;" title="Share on Google+"><span class="character">j</span></a>
Error
错误
This XML file does not appear to have any style information associated with it. The document tree is shown below.
此 XML 文件似乎没有任何与之关联的样式信息。文档树如下所示。
<WSResponse>
<responseInfo>FAILURE_NO_SUBMIT_ACTION</responseInfo> <responseMsg/>
<jsonPayLoad/>
</WSResponse>
Note
笔记
<?php the_permalink(); ?>renders the link of the current site page that you could share on socials networks
<?php the_permalink(); ?>呈现您可以在社交网络上共享的当前站点页面的链接
回答by Imran
I think the problem is you are not doing it in the way linkedin asked to you. You should always refer to API docs first. For example below linkedin describe how you can generate Share Plugin for your site.
我认为问题在于您没有按照linkedin 要求您的方式进行操作。您应该始终首先参考 API 文档。例如下面的linkedin 描述了如何为您的站点生成共享插件。
and the code generated is looks like:
生成的代码如下所示:
<script src="//platform.linkedin.com/in.js" type="text/javascript"> lang: en_US</script>
<script type="IN/Share" data-url="Your_URL_Here" data-counter="top"></script>
Also you can do it in following way:
您也可以通过以下方式进行:
https://www.linkedin.com/shareArticle?mini=true&url=http://developer.linkedin.com&title=LinkedIn%20Developer%20Network&summary=My%20favorite%20developer%20program&source=LinkedIn
Reference: Share on Linkedin
参考:在Linkedin上分享
Your link will look like:
您的链接将如下所示:
https://www.linkedin.com/shareArticle?mini=true&url=<?php the_permalink(); ?>&title=Some%20Title&summary=Some%20Summary&source=YourWebsiteName
Where mini parameter is for: A required argument who's value must always be: true
迷你参数用于: 一个必需的参数,其值必须始终为:true
and Source is: The url-encoded source of the content (e.g. your website or application name) Please let me know if you still needs to know how it will work for you.
和来源是:内容的 url 编码来源(例如您的网站或应用程序名称)如果您仍然需要知道它将如何为您工作,请告诉我。
And all parameters must be URL Encoded.
并且所有参数都必须是 URL Encoded。
回答by Kishan Chauhan
You can just change in onclick url linkedin 'share?url=' to 'shareArticle?mini=true&', i think it's help.
您可以将 onclick url linkedin 'share?url=' 更改为 'shareArticle?mini=true&',我认为这很有帮助。
<a class="btn btn-default icon" href="javascript:void(0)" onclick="window.open( 'http://www.linkedin.com/shareArticle?mini=true&url=<?php the_permalink(); ?>', 'sharer', 'toolbar=0, status=0, width=626, height=436');return false;" title="Linkedin"><span class="character">j</span></a>
回答by Nikola
I use this very simple sharer:
我使用这个非常简单的共享器:
<a href="https://www.linkedin.com/sharing/share-offsite/?url=your-url-here.com"target="_blank" title="Share on LinkedIn">
Share on LinkedIn
</a>
This is how it looks like: Example of using simple LinkedIn sharer in Google Chrome
回答by clement
You should better use the linkeidn script, or see what he generate exactly
你最好使用linkeidn脚本,或者看看他到底生成了什么
<script src="//platform.linkedin.com/in.js" type="text/javascript"> lang: en_US</script>
<script type="IN/Share" data-url="<?php the_permalink(); ?>" data-counter="top"></script>
source: linkedin developper
来源:linkedin 开发者
回答by Rohit Grover
This script to be added at the top
此脚本要添加在顶部
<script src="//platform.linkedin.com/in.js" type="text/javascript"> lang:en_US</script>
and if you want to use linkedin button on a popup then you have to insert following script in the html.
如果你想在弹出窗口中使用linkedin按钮,那么你必须在html中插入以下脚本。
<script type="IN/Share" data-url="http://linkedin.com">
</script>
回答by Alexander Mills
I got it to work like this (very simple):
我让它像这样工作(非常简单):
<a target="_blank" title="Share on LinkedIn"
href="http://www.linkedin.com/shareArticle?mini=true&url={{your-content-here.com}}">
</a>
this will open a new tab (at least in Chrome), and looks like this:
这将打开一个新标签(至少在 Chrome 中),如下所示:
In my case, is a link to Chrome Webstorm item url. Because I'd like share my Chrome Extension App, on various social media sites.
就我而言,是指向 Chrome Webstorm 项目 url 的链接。因为我想在各种社交媒体网站上分享我的 Chrome 扩展应用程序。


