前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >facebook|Twitter|linkedin分享

facebook|Twitter|linkedin分享

作者头像
奋飛
发布2019-08-15 16:15:05
1.2K0
发布2019-08-15 16:15:05
举报
文章被收录于专栏:Super 前端Super 前端

版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。

本文链接:https://ligang.blog.csdn.net/article/details/44977279

代码语言:javascript
复制
<!DOCTYPE html>
<html lang="en" prefix="og: http://ogp.me/ns#">
<head>
	<meta charset="UTF-8">
	<title>Document</title>

	<!-- facebook、linked参数配置 start -->
	<meta property="og:site_name" content="site name"/>
	<meta property="og:title" content="title"/>
	<meta property="og:type" content="website"/>
	<meta property="og:description" content="description"/>
	<meta property="og:image" content="http://yourdomain.com/images/hatenablog.png"/>
	<meta property="og:url" content="http://yourdomain.com/test.htm">
	<!-- facebook、linked参数配置 end -->
	
	<!-- Twitter参数配置 start -->
	<meta name="twitter:card" content="http://yourdomain.com/images/logo_fb.jpg">
	<meta name="twitter:site" content="@yourdomain">
	<meta name="twitter:title" content="test title">
	<meta name="twitter:description" content="Up than 200 characters.">
	<meta name="twitter:creator" content="@creator_username">
	<meta name="twitter:image:src" content="http://yourdomain.com/images/logo_fb.jpg">
	<meta name="twitter:domain" content="content">
	<!-- Twitter参数配置 end -->

</head>
<body>
	<!-- facebook分享 start -->
	<script>
		function fbs_click(){
			window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent('http://yourdomain.com/test.htm?facebook=123'),'facebook share','toolbar=0,status=0,width=626,height=436');
			return false;
		}
	</script>
	<a οnclick="return fbs_click()" target="_blank">
		<img src="ADD_IMAGE_URL_HERE" alt="Share on Facebook" />
	</a>
	<!-- facebook分享 end -->
	
	<!-- Twitter分享 start -->
	<script>
		function twitter_click(){
			window.open('https://twitter.com/intent/tweet?hashtags=Invitedusers&original_referer=http://yourdomain.com/test.htm&related=domain&text=Content Test&tw_p=tweetbutton&url='+encodeURIComponent('http://yourdomain.com/test.htm?twitter=123')+'&via=ligang','share','toolbar=0,status=0,width=626,height=436');
			return false;
		}
	</script>
	<a οnclick="return twitter_click()" target="_blank">
		<img src="ADD_IMAGE_URL_HERE" alt="Share on Twitter">
	</a>
	<!-- Twitter分享 end -->


	<!-- Linkedin分享 start-->
	<script>
		function linkedin_click(){
			window.open('https://www.linkedin.com/cws/share?url='+encodeURIComponent('http://yourdomain/test.htm?linkedin=123')+'&token=&isFramed=false&lang=en_US','Linkedin share','toolbar=0,status=0,width=626,height=436');
			return false;
		}
	</script>
	<a οnclick="return linkedin_click();" target="_blank">
		<img src="ADD_IMAGE_URL_HERE" alt="Share on Linkedin">
	</a>
	<!-- Linkedin分享 end-->


	<script src="//platform.linkedin.com/in.js" type="text/javascript"></script>
  	<script type="in/share" data-url="http://tzyourdomain.com/test.htm" data-counter="top"></script>

</body>
</html>

注意问题: 1. facebook和linkedin对于"sample open graph meta tags"的要求格式一样,所以如果同一个页面既要做facebook又要做linkedin,对于图片等信息必须一致 2. linkedin具有七天缓存期限,官方原文“The first time that LinkedIn's crawlers visit a webpage when asked to share content via a URL, the data it finds (Open Graph values or our own analysis) will be cached for a period of approximately 7 days.” 开发文档 facebook:https://developers.facebook.com/docs?locale=zh_CN Twitter:https://dev.twitter.com/web/embedded-tweets linked:https://developer.linkedin.com/docs

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2015年04月10日,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档