转:一切整合分享到新浪网易微博代码

来自:http://www.taoba123.com/show.asp?id=7392

近期,国内外微博火热,大有全民一起写微博之气,但随着微博流行,人们渐渐的习惯把生活、工作、学习、娱乐等方面的消息发到微博上,为此本人整理了主流微博分享代码,供大家使用。 

    一、新浪微博分享代码:

   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%20f='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%20a(){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%20a();})(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> 的链接样式及文字可自行据需求修改.代码中有 " %20f " 属正常代码,无需处理 

    3、非官方正式代码: 

 

 

    1)、<a href="http://v.t.sina.com.cn/share/share.php?title=%E4%BD%A0%E5%A5%BD%20hello%20world" target="_blank">分享到微博</a>,简单分享(无需申请) 

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

    字段需要经过encodeURIComponent,例子: 
你好 http://t.sina.com.cn/ -&gt <script>document.write(encodeURIComponent("你好 http://t.sina.com.cn/"));</script> 

 

    注:Appkey需要前往 open.t.sina.com.cn 申请


    二、网易微博分享代码 

    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> 

    2、样式二

 

 

<a target="_self" onclick="(function(){var url = 'link=http://news.163.com/&amp;source='+ encodeURIComponent('网易新闻')+ '&amp;info='+ encodeURIComponent(document.title) + ' ' + encodeURIComponent(document.location.href);window.open('http://t.163.com/article/user/checkLogin.do?'+url+'&amp;'+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>

 

   以上代码简单实用,是您给自己博客、网站居家必备秘密武器,祝您使用愉快。=^_^=(文/猴子)


posted on 2011-01-26 09:24  Sammy  阅读(1811)  评论(0编辑  收藏  举报

导航