现在SNS网站极为广泛,通过SNS的网络化和人际关系传播推广内容已经是各个网站经常采用的手段。
也有一些网站或者组织提供了相应的集成工具 比如
http://www.jiathis.com/getcode/ 等,这类工具的特点是强大,完善,覆盖面广,当然如果你只需要主要的几个,也可以自己定义。
其实分享到各个网站的功能是通过 各SNS网站的一个连接接口实现的。只要分析掌握了各个网站分享连接的组成规律,再用脚本等进行组合,生成相应连接地址即可。
下为笔者写的一个简单的分享功能,它有简单的设置功能,设置分享的连接和标题,如果不设置,则默认取当前页面的URL 和 title
/*
*Share Tools 2011-06-16
*全局设置格式
sharetools.config
*/
var sharetools = sharetools || {};
sharetools.config = {
title:"",
url:"",
pretxt:""
};
sharetools._appkey = encodeURI("KEY需要你自己申请");
sharetools._site = 'http://i.qsl.cn';
sharetools.shareurls = [
'http://v.t.qq.com/share/share.php?url=$$SHAREURL&title=$$SHARETITLE' + '&appkey='+ sharetools._appkey + '&site=' + sharetools._site,
'http://v.t.sina.com.cn/share/share.php?url=$$SHAREURL&title=$$SHARETITLE',
'http://www.kaixin001.com/repaste/share.php?rurl=$$SHAREURL&rcontent=$$SHAREURL&rtitle=$$SHARETITLE',
'http://share.renren.com/share/buttonshare.do?link=$$SHAREURL&title=$$SHARETITLE',
'http://www.douban.com/recommend/?url=$$SHAREURL&title=$$SHARETITLE',
'http://bai.sohu.com/share/blank/add.do?link=$$SHAREURL',
'http://apps.hi.baidu.com/share/?url=$$SHAREURL',
'http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url=$$SHAREURL&title=$$SHARETITLE'
];
sharetools.snstitles = [
'分享到腾讯微博',
'分享到新浪微博',
'分享到开心网',
'分享到人人网',
'分享到豆瓣',
'分享到搜狐白社会',
'分享到百度空间',
'分享到QQ空间'
];
sharetools.init = function(id){
sharetools.id = id;
var sharecnt = $("#"+sharetools.id);
if(!sharecnt.length) return;
var sharetoolscss = $("#sharetoolscss");
if(!sharetoolscss.length){
$('<link type="text/css" href="http://stc.qsl.cn/styles/i/sharetools.css" rel="stylesheet" media="all" >));
*Share Tools 2011-06-16
*全局设置格式
sharetools.config
*/
var sharetools = sharetools || {};
sharetools.config = {
title:"",
url:"",
pretxt:""
};
sharetools._appkey = encodeURI("KEY需要你自己申请");
sharetools._site = 'http://i.qsl.cn';
sharetools.shareurls = [
'http://v.t.qq.com/share/share.php?url=$$SHAREURL&title=$$SHARETITLE' + '&appkey='+ sharetools._appkey + '&site=' + sharetools._site,
'http://v.t.sina.com.cn/share/share.php?url=$$SHAREURL&title=$$SHARETITLE',
'http://www.kaixin001.com/repaste/share.php?rurl=$$SHAREURL&rcontent=$$SHAREURL&rtitle=$$SHARETITLE',
'http://share.renren.com/share/buttonshare.do?link=$$SHAREURL&title=$$SHARETITLE',
'http://www.douban.com/recommend/?url=$$SHAREURL&title=$$SHARETITLE',
'http://bai.sohu.com/share/blank/add.do?link=$$SHAREURL',
'http://apps.hi.baidu.com/share/?url=$$SHAREURL',
'http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url=$$SHAREURL&title=$$SHARETITLE'
];
sharetools.snstitles = [
'分享到腾讯微博',
'分享到新浪微博',
'分享到开心网',
'分享到人人网',
'分享到豆瓣',
'分享到搜狐白社会',
'分享到百度空间',
'分享到QQ空间'
];
sharetools.init = function(id){
sharetools.id = id;
var sharecnt = $("#"+sharetools.id);
if(!sharecnt.length) return;
var sharetoolscss = $("#sharetoolscss");
if(!sharetoolscss.length){
$('<link type="text/css" href="http://stc.qsl.cn/styles/i/sharetools.css" rel="stylesheet" media="all" >));