您的位置:首页 > 编程语言

常用微博分享代码

2012-12-11 12:56 176 查看
本文出自:http://hi.baidu.com/343362933/blog/item/9e697d191020221635fa4108.html

新浪微博:

1、各网站、论坛、博客等通用代码: <a href=”javascript:(function(){window.open(‘http://v.t.sina.com.cn/share/share.php?title=’+encodeURIComponent(document.title)+’&url=’+encodeURIComponent(location.href)+’&source=bookmark’,'_blank’,'width=450,height=400′);})()” title=”新浪微博分享”><img
src=”http://t.sina.com.cn/favicon.ico” alt=”新浪微博分享” border=”0〃>分享到新浪微博</a>

此代码无需申请 Appkey

2、新浪官方分享到代码:

<a href=”javascript:void((function(s,d,e,r,l,p,t,z,c) {var f=’http://v.t.sina.com.cn/share/share.php?appkey=真实的 appkey’,u=z||d.location,p=['&url=',e(u),'& title=',e(t||d.title),'&source=',e(r),'&sourceUrl=',e(l),'& content=',c||'gb2312','&pic=',e(p||'')].join(”);function
a() {if(!window.open([f,p].join(”),’mb’, ['toolbar=0,status=0,resizable=1,width=440,height=430,left=',(s.width- 440)/2,',top=',(s.height-430)/2].join(”)))u.href=[f,p].join(”);}; if(/Firefox/.test(navigator.userAgent))setTimeout(a,0);else a();}) (screen,document,encodeURIComponent,”,”,’图片链接|默认为空’,'标题|默认当前页标题’,'内容链接|默认当前页location’,'页面编码gb2312|utf-8默认gb2312′));”>分享至微博</a>

注意事项说明:?
此需要申请appkey帐号,地址:open.t.sina.com.cn
真实的appkey {string} 必选参数?
图片链接 (String) 可选参数, 默认为空?
标题 (String) 可选参数, 默认当前页title?
内容链接 (String) 可选参数, 默认当前页location?
页面编码 (String) 可选参数, [gb2312|utf-8] 默认gb2312?
<a> 的链接样式及文字可自行据需求修改.代码中有 ” f ” 属正常代码,无需处理

3、非官方正式代码:

1)、<a href=”http://v.t.sina.com.cn/share/share.php?title=你好 hello world” target=”_blank”>分享到微博</a>,简单分享(无需申请)

2)、<a href=”http://v.t.sina.com.cn/share/share.php?appkey=4120396272&title=你好 hello world” target=”_blank”>分享到微博</a>,带有AppKey(Appkey需要前往 open.t.sina.com.cn 申请)

字段需要经过encodeURIComponent,例子:

你好 http://t.sina.com.cn/ -> <script>document.write(encodeURIComponent(“你好 http://t.sina.com.cn/”));</script>
注:Appkey需要前往 open.t.sina.com.cn 申请

开心网:

document.writeln("<a href="javascript:window.open(\'http:\/\/www.kaixin001.com\/repaste\/share.php?rtitle=\'+encodeURIComponent(document.title.substring(0,76))+\'&rurl=\'+encodeURIComponent(location.href)+\'&rcontent=\',\'_blank\',\'scrollbars=no,width=600,height=450,left=75,top=20,status=no,resizable=yes\');
void 0" style="color:#000000;text-decoration:none;font-size:12px;font-weight:normal"><SPAN style="PADDING-RIGHT: 5px; PADDING-LEFT: 5px; FONT-SIZE: 12px; PADDING-BOTTOM: 0px; MARGIN-LEFT: 10px; CURSOR: pointer; PADDING-TOP: 5px"><IMG alt=转帖到开心网 src="http:\/\/img1.kaixin001.com.cn\/i\/favicon.ico"
align=absMiddle border=0> 转帖到开心网<\/SPAN><\/a>");

人人网:

document.writeln("<a href="javascript:window.open(\'http://share.renren.com/share/buttonshare.do?title=\'+encodeURIComponent(document.title.substring(0,76))+\'&link=\'+encodeURIComponent(location.href)+\'&content=\',\'_blank\',\'scrollbars=no,width=600,height=450,left=75,top=20,status=no,resizable=yes\');
void 0" style="color:#000000;text-decoration:none;font-size:12px;font-weight:normal"><SPAN style="PADDING-RIGHT: 5px; PADDING-LEFT: 5px; FONT-SIZE: 12px; PADDING-BOTTOM: 0px; MARGIN-LEFT: 10px; CURSOR: pointer; PADDING-TOP: 5px"><IMG alt=转帖到人人网 src="http:\/\/s.xnimg.cn\/favicon-rr.ico"
align=absMiddle border=0> 转帖到人人网<\/SPAN><\/a><\/div>");

网易微博分享代码

1、样式一:任何网站、博客都可以调用

<a href=”javascript:(function(){window.open(‘http://t.163.com/article/user /checkLogin.do?link=http://news.163.com/&source=’+'土豆网’+ ‘&info=’+encodeURIComponent(document.title)+’ ‘+encodeURIComponent(location.href),’_blank’,'width=510,height=300′);})()” title=”分享到网易微博”><img
src=”http://www.taoba123.com/images/resource_10544871274700952v.png” alt=”网易微博分享” border=”0〃></a>

<a href=”javascript:(function(){window.open(‘http://t.163.com/article/user /checkLogin.do?link=http://news.163.com/&source=’+'土豆网’+ ‘&info=’+encodeURIComponent(document.title)+’ ‘+encodeURIComponent(location.href),’_blank’,'width=510,height=300′);})()” title=”分享到网易微博”><img
src=”http://www.taoba123.com/images/resource_10544871274700952v.png” alt=”网易微博分享” border=”0〃></a>

2、样式二

<a target=”_self” onclick=”(function(){var url = ‘link=http://news.163.com/&source=’+ encodeURIComponent(‘网易新闻’)+ ‘&info=’+ encodeURIComponent(document.title) + ‘ ‘ + encodeURIComponent(document.location.href);window.open(‘http://t.163.com/article/user/checkLogin.do?’+url+’&’+new
Date().getTime(),’newwindow’,'height=330,width=550,top=’+(screen.height-280)/2+’,left=’+(screen.width-550)/2+’, toolbar=no, menubar=no, scrollbars=no,resizable=yes,location=no, status=no’);})()” href=”javascript:void(0);”><img height=”19px” border=”0〃 align=”absMiddle”
src=”http://img1.cache.netease.com/cnews/css09/wblog.gif” alt=”分享到网易微博” title=”分享到网易微博” />分享到网易微博</a>

<a target=”_self” onclick=”(function(){var url = ‘link=http://news.163.com/&source=’+ encodeURIComponent(‘网易新闻’)+ ‘&info=’+ encodeURIComponent(document.title) + ‘ ‘ + encodeURIComponent(document.location.href);window.open(‘http://t.163.com/article/user/checkLogin.do?’+url+’&’+new
Date().getTime(),’newwindow’,'height=330,width=550,top=’+(screen.height-280)/2+’,left=’+(screen.width-550)/2+’, toolbar=no, menubar=no, scrollbars=no,resizable=yes,location=no, status=no’);})()” href=”javascript:void(0);”><img height=”19px” border=”0〃 align=”absMiddle”
src=”http://img1.cache.netease.com/cnews/css09/wblog.gif” alt=”分享到网易微博” title=”分享到网易微博” />分享到网易微博</a>

搜狐微博分享代码

javascript:void(((function(s,d,e){var f='http://t.sohu.com/third/post.jsp?&url='+e(location.href)+'&title='+e(d.title),u=d.location;function a(){if(!window.open(f,'sohushare',['toolbar=0,status=0,resizable=1,width=660,height=470,left=',(s.width-660)/2,',top=',(s.height-470)/2].join('')))u.href=f;};if(-[1,])setTimeout(a,0);else
a();})(screen,document,escape)))
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: