100字范文,内容丰富有趣,生活中的好帮手!
100字范文 > 桌面网页上实现分享功能 分享到QQ空间 新浪微博 人人网

桌面网页上实现分享功能 分享到QQ空间 新浪微博 人人网

时间:2022-03-23 21:59:24

相关推荐

桌面网页上实现分享功能 分享到QQ空间 新浪微博 人人网

重要声明:本文章仅仅代表了作者个人对此观点的理解和表述。读者请查阅时持自己的意见进行讨论。

本文原文地址:桌面网页上实现分享功能,分享到QQ空间、新浪微博、人人网

在桌面网页上发现好文章时用户往往选择分享给朋友,而这时我们如何实现分享呢,本文列出了分享到:QQ、QQ空间、新浪微博、人人网 的api和分享代码。你不必再去到处找了。

1、分享到QQ

API接口:/widget/shareqq/index.html

参数:

2、分享到QQ空间

API接口:https://sns./cgi-bin/qzshare/cgi_qzshare_onekey

参数:

3、分享到新浪微博

API接口:/share/share.php

参数:

4、分享到人人网

API接口:/dialog/share

参数:

5、代码

下面的代码封装了所列出的所有分享,你可以直接COPY,代码里包含了本站的首页地址,复制的时候记得改成自己的站点地址哦

var ShareUtil = {openShareUrl: function (url) {var a = document.createElement("a");a.href = url;a.target = "_blank";a.click();},shareToQQ: function (option) {var url = "/widget/shareqq/index.html" +"?url="+ encodeURIComponent(option.url)+"&title=" + encodeURIComponent(option.title) +"&source=" + encodeURIComponent('') +"&summary=" + encodeURIComponent(option.desc)+"&pics=" + encodeURIComponent(option.pics)+"&desc=" + encodeURIComponent(option.summary);ShareUtil.openShareUrl(url);},shareToQZone: function (option) {var url = "https://sns./cgi-bin/qzshare/cgi_qzshare_onekey" +"?url="+ encodeURIComponent(option.url)+"&title=" + encodeURIComponent(option.title) +"&summary=" + encodeURIComponent(option.desc)+"&desc=" + encodeURIComponent(option.summary) +"&site=" + encodeURIComponent('')+"&pics=" + encodeURIComponent(option.pics);ShareUtil.openShareUrl(url);},shareToWeibo: function (option) {var url = "/share/share.php" +"?url="+ encodeURIComponent(option.url)+"&title=" + encodeURIComponent(option.title + "。" + option.desc) +"&pic="+ encodeURIComponent(option.pics)+"&appkey=" + encodeURIComponent(option.appkey);ShareUtil.openShareUrl(url);},shareToRenren: function (option) {var url = '/dialog/share' +'?resourceUrl=' + encodeURIComponent(option.url) +'&srcUrl=' + encodeURIComponent('') +"&title="+ encodeURIComponent(option.title) +"&description=" + encodeURIComponent(option.desc)+"&pic=" + encodeURIComponent(option.pics);ShareUtil.openShareUrl(url);}}

然后你就可以使用ShareUtil里面的方法进行分享啦。记得为此博文点赞分享哦。

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。