其中官方提供的代码如下:
分享到SNS一键分享按钮代码介绍:
·腾讯微博:http://open.t.qq.com/apps/share/explain.php
·新浪微博:http://open.weibo.com/sharebutton
·开心网:http://www.kaixin001.com/platform/?app=repaste
·人人网:http://widget.renren.com/?widget=freeshare
·搜狐微博:http://open.t.sohu.com/en/%E4%B8%80%E9%94%AE%E5%88%86%E4%BA%AB%E5%88%B0%E6%90%9C%E7%8B%90%E5%BE%AE%E5%8D%9A
·网易微博:http://open.t.163.com/components/onekey
但是有些站点提供的api不是很好用喔。大概的简化一下。部分可以实现 标题,内容,图片,连接的分享。
var title = encodeURIComponent("标题文字");
var url = encodeURIComponent(document.location);
var content = encodeURIComponent("介绍文字~~~哈哈!!!");
var pic = encodeURI('http://localhost/images/index/banner.gif');
var site = http://www.sendnet.cn;
===========================================================================================
//分享到腾讯围脖
function postToQQ() {
var _t = title;
var _url = url;
var _appkey = encodeURI('appkey');//你从腾讯获得的appkey
var _pic = pic;//(例如:var _pic='图片url1|图片url2|图片url3....)
var _txt = content;
var _site = site;//你的网站地址
var _u = 'http://v.t.qq.com/share/share.php?url=' + _url + '&appkey='
+ _appkey + '&site=' + _site + '&pic=' + _pic + '&title=' + _t
+ _txt;
window.open(_u,'','width=700, height=680, top=0, left=0, toolbar=no, menubar=no, scrollbars=no, location=yes, resizable=no, status=no');
}
//分享到开心网
function postToKaixin() {
window.open('http://www.kaixin001.com/repaste/share.php?rtitle='
+ title + '&rurl=' + url + '&rcontent=' + content);
}
//分享到网易围脖
function postTo163() {
var url = '&info=' +title+ content + ' ' + encodeURIComponent(document.location.href)
+'&images='+pic;
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');
}
//分享到新浪围脖
function postToSina() {
window.open('http://service.weibo.com/share/share.php?url='+url+'&appkey=&title='+title+content+'&pic='+pic+'+&ralateUid=');
//window.open('http://v.t.sina.com.cn/share/share.php?title=' + title+ content+'&url=' + url);
}
//分享到人人网
function postToRenRen() {
window.open('http://share.renren.com/share/buttonshare.do?link='+url+'&title='+title);
}
//分享到搜狐围脖
function postToSoho() {
window.open('http://t.sohu.com/third/post.jsp?&title='+encodeURIComponent(title)+'&url='+encodeURIComponent(content)+location.href);
}