//图片自己去下载,这里只是简单的几个分享
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<div class="share_top_style">
<a href="javascript:void()" class="" onClick="dofristshare('sina')"><img src="images/sina.png" alt="新浪微博"></a>
<a href="javascript:void()" class="" onClick="dofristshare('tx')"><img src="images/tx.png" alt="腾讯微博"></a>
<a href="javascript:void()" class="" onClick="dofristshare('rr')"><img src="images/rr.png" alt="人人网"></a>
<a href="javascript:void()" class="" onClick="dofristshare('qzone')"><img src="images/qq.png" alt="QQ空间"></a>
<a href="javascript:void()" class="" onClick="dofristshare('douban')"><img src="images/db.png" alt="豆瓣"></a>
<a href="javascript:void()" class="" onClick="dofristshare('tieba')"><img src="images/db.png" alt="百度贴吧"></a>
<a href="javascript:void()" class="" onClick="dofristshare('kaixin')"><img src="images/db.png" alt="开心网"></a>
</div>
<script type="text/javascript">
function dofristshare(type) {
var title = encodeURIComponent("新年快乐,马年吉祥");
var link = encodeURIComponent('http://www.baidu.com');
var image = encodeURIComponent('http://www.baidu.com/img/bdlogo.gif');
if(type == "sina") {
window.open("http://v.t.sina.com.cn/share/share.php?url=" + link + "&title=" + title + "&content=utf8&pic=" + image);
}
if(type == "tx") {
window.open("http://v.t.qq.com/share/share.php?url=" + link + "&title=" + title + "&pic=" + image);
}
if(type == "qzone") {
window.open("http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url=" + link + "&title=" + title + "&pics=" + image);
}
if(type == "rr") {
window.open("http://widget.renren.com/dialog/share?resourceUrl=" + link + "&title=" + title + "&pic=" + image);
}
if(type == "douban") {
window.open("http://www.douban.com/recommend/?url=" + link + "&title=" + title + "&image=" + image);
}
if(type == "tieba") {
window.open("http://tieba.baidu.com/f/commit/share/openShareApi?url=" + link + "&title=" + title + "&pic=" + image);
}
if(type == "kaixin") {
window.open("http://www.kaixin001.com/repaste/share.php?url=" + link + "&content=" + title + "&pic=" + image + '&style=11');
}
return false;
}
</script>
</body>
</html>
下面是一些分享接口
1.分享到微信,易信
分享到微信,易信比较简单,贴上分享链接的二维码就可以了。
二维码生成地址:http://cli.im/ (网上随便搜的)
2.分享到新浪微博
代码如下:
var _shareUrl = 'http://v.t.sina.com.cn/share/share.php?&appkey=895033136'; //真实的appkey ,必选参数 _shareUrl += '&url='+ encodeURIComponent(_url||document.location); //参数url设置分享的内容链接|默认当前页location,可选参数 _shareUrl += '&title=' + encodeURIComponent(_title||document.title); //参数title设置分享的标题|默认当前页标题,可选参数 _shareUrl += '&source=' + encodeURIComponent(_source||''); _shareUrl += '&sourceUrl=' + encodeURIComponent(_sourceUrl||''); _shareUrl += '&content=' + 'utf-8'; //参数content设置页面编码gb2312|utf-8,可选参数 _shareUrl += '&pic=' + encodeURIComponent(_pic||''); //参数pic设置图片链接|默认为空,可选参数 window.open(_shareUrl,'_blank','toolbar=no,menubar=no,scrollbars=no,resizable=1,location=no,status=0,' + 'width=' + _width + ',height=' + _height + ',top=' + (screen.height-_height)/2 + ',left=' + (screen.width-_width)/2);
appkey为必填参数。
详情请参考:http://open.weibo.com/wiki/ShareCode
3.分享到QQ空间
代码如下:
var _shareUrl = 'http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?'; _shareUrl += 'url=' + encodeURIComponent(_url||document.location); //参数url设置分享的内容链接|默认当前页location _shareUrl += '&showcount=' + _showcount||0; //参数showcount是否显示分享总数,显示:'1',不显示:'0',默认不显示 _shareUrl += '&desc=' + encodeURIComponent(_desc||'分享的描述'); //参数desc设置分享的描述,可选参数 _shareUrl += '&summary=' + encodeURIComponent(_summary||'分享摘要'); //参数summary设置分享摘要,可选参数 _shareUrl += '&title=' + encodeURIComponent(_title||document.title); //参数title设置分享标题,可选参数 _shareUrl += '&site=' + encodeURIComponent(_site||''); //参数site设置分享来源,可选参数 _shareUrl += '&pics=' + encodeURIComponent(_pic||''); //参数pics设置分享图片的路径,多张图片以"|"隔开,可选参数 window.open(_shareUrl,'_blank','width='+_width+',height='+_height+',top='+(screen.height-_height)/2+',left='+(screen.width-_width)/2+',toolbar=no,menubar=no,scrollbars=no,resizable=1,location=no,status=0');详情请参考:http://connect.qq.com/intro/share/
4.分享到百度贴吧
代码如下:
var _shareUrl = 'http://tieba.baidu.com/f/commit/share/openShareApi?'; _shareUrl += 'title=' + encodeURIComponent(_title||document.title); //分享的标题 _shareUrl += '&url=' + encodeURIComponent(_url||document.location); //分享的链接 _shareUrl += '&pic=' + encodeURIComponent(_pic||''); //分享的图片 window.open(_shareUrl,'_blank','width='+_width+',height='+_height+',left='+(screen.width-_width)/2+',top='+(screen.height-_height)/2+',toolbar=no,menubar=no,scrollbars=no, resizable=1,location=no,status=0');详情请参考:http://share.baidu.com/code/advance
5.分享到豆瓣
代码如下:
var _shareUrl = 'http://shuo.douban.com/!service/share?'; _shareUrl += 'href=' + encodeURIComponent(_url||location.href); //分享的链接 _shareUrl += '&name=' + encodeURIComponent(_title||document.title); //分享的标题 _shareUrl += '&image=' + encodeURIComponent(_pic||''); //分享的图片 window.open(_shareUrl,'_blank','width='+_width+',height='+_height+',left='+(screen.width-_width)/2+',top='+(screen.height-_height)/2+',toolbar=no,menubar=no,scrollbars=no,resizable=1,location=no,status=0');
6.分享到腾迅微博
代码如下:
var _shareUrl = 'http://v.t.qq.com/share/share.php?'; _shareUrl += 'title=' + encodeURIComponent(_title||document.title); //分享的标题 _shareUrl += '&url=' + encodeURIComponent(_url||location.href); //分享的链接 _shareUrl += '&appkey=5bd32d6f1dff4725ba40338b233ff155'; //在腾迅微博平台创建应用获取微博AppKey _shareUrl += '&site=' + encodeURIComponent(_site||''); //分享来源 _shareUrl += '&pic=' + encodeURIComponent(_pic||''); //分享的图片,如果是多张图片,则定义var _pic='图片url1|图片url2|图片url3....' window.open(_shareUrl,'_blank','width='+_width+',height='+_height+',left='+(screen.width-_width)/2+',top='+(screen.height-_height)/2+',toolbar=no,menubar=no,scrollbars=no,resizable=1,location=no,status=0');详情请参考:http://dev.t.qq.com/websites/share/
7.分享到人人网
代码如下:
var _shareUrl = 'http://share.renren.com/share/buttonshare.do?'; _shareUrl += 'link=' + encodeURIComponent(_url||location.href); //分享的链接 _shareUrl += '&title=' + encodeURIComponent(_title||document.title); //分享的标题 window.open(_shareUrl,'_blank','width='+_width+',height='+_height+',left='+(screen.width-_width)/2+',top='+(screen.height-_height)/2+',toolbar=no,menubar=no,scrollbars=no,resizable=1,location=no,status=0');其他的分享内容会从页面中去抓取。
想了解更多,可参考:http://dev.renren.com/website/?widget=rrshare&content=use
8.分享到开心网
代码如下:有两种写法,第一种写法也是跳转到 http://www.kaixin001.com/rest/records.php这个链接地址。
var _shareUrl = 'http://www.kaixin001.com/repaste/share.php?'; _shareUrl += 'rtitle=' + encodeURIComponent(_title||document.title); //分享的标题 window.open(_shareUrl,'_blank','width='+_width+',height='+_height+',left='+(screen.width-_width)/2+',top='+(screen.height-_height)/2+',toolbar=no,menubar=no,scrollbars=no,resizable=1,location=no,status=0');
var _shareUrl = 'http://www.kaixin001.com/rest/records.php?'; _shareUrl += 'url=' + encodeURIComponent(_url||location.href); //分享的链接 _shareUrl += '&content=' + encodeURIComponent('分享的文字'); //需要分享的文字,当文字为空时,自动抓取分享网址的title _shareUrl += '&pic=' + encodeURIComponent(_pic||''); //分享的图片,多个使用半角逗号分隔 _shareUrl += '&showcount=0'; //是否显示分享数,显示:'1',不显示:'0' _shareUrl += '&style=11'; //显示的样式,必选参数 _shareUrl += '&aid=' + encodeURIComponent(_site||''); //显示分享来源 window.open(_shareUrl,'_blank','width='+_width+',height='+_height+',left='+_left+',top='+_top+',toolbar=no,menubar=no,scrollbars=no,resizable=1,location=no,status=0');
9.分享到facebook
代码如下:
var _shareUrl = 'http://www.facebook.com/sharer/sharer.php?'; _shareUrl += 'u=' + encodeURIComponent(_url||location.href); //分享的链接 _shareUrl += '&t=' + encodeURIComponent(_title||document.title); //分享的标题 window.open(_shareUrl,'_blank','width='+_width+',height='+_height+',left='+_left+',top='+_top+',toolbar=no,menubar=no,scrollbars=no,resizable=1,location=no,status=0');
10.分享到Twitter
代码如下:
var _shareUrl = 'http://twitter.com/intent/tweet?'; _shareUrl += 'url=' + encodeURIComponent(_url||location.href); //分享的链接 _shareUrl += '&text=' + encodeURIComponent(_title||document.title); //分享的标题 window.open(_shareUrl,'_blank','width='+_width+',height='+_height+',left='+_left+',top='+_top+',toolbar=no,menubar=no,scrollbars=no,resizable=1,location=no,status=0');