`

一键分享腾讯微博,新浪微博等api(WEB 版)

 
阅读更多
腾讯微博分享

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


------------------------------------------------------------
网易微博分享
<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)


搜狐微博分享代码:

<a  href="javascript:void((function(s,d,e,r,l,p,t,z,c){var f='http://t.sohu.com/third/post.jsp?',u=z||d.location,p=['&url=',e(u),'&title=',e(t||d.title),'&content=',c||'gb2312','&pic=',e(p||'')].join('');function%20a(){if(!window.open([f,p].join(''),'mb',['toolbar=0,status=0,resizable=1,width=660,height=470,left=',(s.width-660)/2,',top=',(s.height-470)/2].join('')))u.href=[f,p].join('');};if(/Firefox/.test(navigator.userAgent))setTimeout(a,0);else%20a();})(screen,document,encodeURIComponent,'','','','','','utf-8'));" title="分享到搜狐微博" class="s3"> </a>

人人网分享代码:

<a  href="javascript:window.open('http://share.renren.com/share/buttonshare.do?title='+encodeURIComponent(document.title.substring(0,76))+'&amp;link='+encodeURIComponent(location.href)+'&amp;content=','_blank','scrollbars=no,width=600,height=450,left=75,top=20,status=no,resizable=yes'); void 0" title="分享到人人网" class="s4"> </a>

开心网分享代码:

<a  href="javascript:window.open('http://www.kaixin001.com/repaste/share.php?rtitle='+encodeURIComponent(document.title.substring(0,76))+'&amp;rurl='+encodeURIComponent(location.href)+'&amp;rcontent=','_blank','scrollbars=no,width=600,height=450,left=75,top=20,status=no,resizable=yes'); void 0" title="分享到开心网" class="s5"> </a>

豆瓣网分享代码:

<a  href="javascript:void(function(){var%20d=document,e=encodeURIComponent,s1=window.getSelection,s2=d.getSelection,s3=d.selection,s=s1?s1():s2?s2():s3?s3.createRange().text:' ',r='http://www.douban.com/recommend/?url='+e(d.location.href)+'&title='+e(d.title)+'&sel='+e(s)+'&v=1',x=function(){if(!window.open(r,'douban','toolbar=0,resizable=1,scrollbars=yes,status=1,width=450,height=330'))location.href=r+'&r=1'};if(/firefox/.test(navigator.userAgent)){setTimeout(x,0)}else{x()}})()" title="分享到豆瓣网" class="s6"> </a>
分享到:
评论
1 楼 wuxiaolan91 2014-06-03  
那个分享到新浪微博去的代码错了呀.那个是分享到网易微博去的.

相关推荐

Global site tag (gtag.js) - Google Analytics