如何创建一个简单的shareIn链接?

时间:2015-04-20 09:30:21

标签: javascript jquery linkedin

我正在使用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>

错误

  

此XML文件似乎没有任何关联的样式信息   用它。文档树如下所示。

<WSResponse>
  <responseInfo>FAILURE_NO_SUBMIT_ACTION</responseInfo> <responseMsg/>
  <jsonPayLoad/> 
</WSResponse>

注意

  

<?php the_permalink(); ?>呈现当前网站页面的链接   您可以在社交网络上分享

7 个答案:

答案 0 :(得分:12)

我认为问题是你不是按照你问你的方式做的。您应该首先参考API文档。例如,下面的linkedin描述了如何为您的站点生成共享插件。

Share Plugin Generator

生成的代码如下:

<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>

您也可以通过以下方式完成:

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

参考:Share on Linkedin

您的链接如下:

https://www.linkedin.com/shareArticle?mini=true&url=<?php the_permalink(); ?>&title=Some%20Title&summary=Some%20Summary&source=YourWebsiteName

mini参数用于:必需参数的值必须始终为:true

和来源是:内容的网址编码来源(例如您的网站或应用名称) 如果你仍然需要知道它对你有什么用,请告诉我。

所有参数都必须是URL编码。

答案 1 :(得分:4)

您可以更改onclick url linkedin&#39; share?url =&#39; to&share; shareArticle?mini = true&amp;&#39;,我认为这有帮助。

<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>

答案 2 :(得分:1)

你应该更好地使用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>

来源:linkedin developper

答案 3 :(得分:1)

我使用这个非常简单的共享器:

<a href="https://www.linkedin.com/sharing/share-offsite/?url=your-url-here.com"target="_blank" title="Share on LinkedIn">
Share on LinkedIn
</a>

它是这样的: Example of using simple LinkedIn sharer in Google Chrome

答案 4 :(得分:0)

此脚本将添加到顶部

<script src="//platform.linkedin.com/in.js" type="text/javascript"> lang:en_US</script>

如果你想在弹出窗口中使用linkedin按钮,那么你必须在html中插入以下脚本。

<script type="IN/Share" data-url="http://linkedin.com">
            </script>

答案 5 :(得分:0)

我让它像这样工作(非常简单):

 <a target="_blank" title="Share on LinkedIn"
     href="http://www.linkedin.com/shareArticle?mini=true&url={{your-content-here.com}}">
 </a>

这将打开一个新标签(至少在Chrome中),如下所示:

enter image description here

就我而言,是指向Chrome Webstorm项目网址的链接。因为我想在各种社交媒体网站上分享我的Chrome扩展应用。

答案 6 :(得分:0)

第1步-正确获取网址

使用此URL格式...

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

来源:Official MSD LinkedIn Share Documentation

第2步-处理标题,说明,图片等

在HTML的og:块中设置<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 Share Documentation: Making Your Website Shareable on LinkedIn

第3步-验证一切正常

使用 LinkedIn Post Inspector 。在此处插入您的URL(example.com,而不是您要与之共享的URL(linkedin.com?url=example.com)。

相关问题