腾讯、网易、新浪微博分享接口

bossbusy 2014-03-12

腾讯微博分享:

<script type="text/javascript">
function postToWb(){
var _t = encodeURI('${(activity.intro)!}');//'${(activity.intro)!}'这是取得Action穿过来的值,如果想取当前标题改为document.title
var _url = encodeURI(document.location);
var _appkey = encodeURI("appkey");//你从腾讯获得的appkey
var _pic = encodeURI('');//(列如:var _pic='图片url1|图片url2|图片url3....)
var _site = '';//你的网站地址
var _u = 'http://v.t.qq.com/share/share.php?title='+_t+'&url='+_url+'&appkey='+_appkey+'&site='+_site+'&pic='+_pic;
window.open( _u,'转播到腾讯微博', 'width=700, height=680, top=0, left=0, toolbar=no, menubar=no, scrollbars=no, location=yes, resizable=no, status=no' );
}
</script>

 在页面中加入超链接:

  <a href="javascript:void(0)" onclick="postToWb();" class="tmblog">腾讯微博</a>

新浪微博分享

在页面中直接加入以下代码:

<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=962772401',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=600,height=500,left=',(s.width- 600)/2,',top=',(s.height-600)/2].join('')))u.href=[f,p].join('');}; if(/Firefox/.test(navigator.userAgent))setTimeout(a,0);else%20a();}) (screen,document,encodeURIComponent,'','','www.leziyou.com(如果此处为空会取当前页面网址)','写内容的地方','','utf-8'));" alt="分享到新浪微博" title="分享到新浪微博">新浪微博</a>

网易微博分享

在页面中直接加入以下代码

<a target="_self" onclick="(function(){var url = 'link=http://news.163.com/&amp;source='+ encodeURIComponent('网易新闻')+ '&amp;info='+ encodeURIComponent('${(activity.intro)!}') + ' ' + 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" alt="分享到网易微博" title="分享到网易微博" />网易微博</a>
//其中encodeuRIComponent('${(activity.intro)}')我取的是action传过来的值,如果想取当前页面标题改为encodeuRIComponent(document.title)

相关推荐