微信小程序> 一键分享到QQ空间QQ好友新浪微博微信代码-微博怎样不分享小程序-新浪微博小程序

一键分享到QQ空间QQ好友新浪微博微信代码-微博怎样不分享小程序-新浪微博小程序

浏览量:1447 时间: 来源:维克拉玛蒂亚perry
通过qq空间、qq聊天、新浪微博和微信二维码分享平台提供的接口,实现把网页中对应的图片、标题、描述的信息参数用javascript获取后传进接口中,实现一键分享。

使用到的接口:

1.分享到QQ空间接口:https://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url你的网址sharesourceqzonetitle你的分享标题pics你的分享图片summary你的分享描述信息

2.分享给QQ好友接口:http://connect.qq.com/widget/shareqq/index.html?url你的分享网址sharesourceqzonetitle你的分享标题pics你的分享图片地址summary你的分享描述desc你的分享简述

3.分享到新浪微博接口:http://service.weibo.com/share/share.php?url你的分享网址sharesourceweibotitle你的分享标题pic你的分享图片appkey你的key,需要在新浪微博开放平台中申请

一键分享代码参考如下:

htmldivclass"fl"分享到:/divdivonclick"shareTo('qzone')"imgsrc"http://zixuephp.net/static/images/qqzoneshare.png"width"30"/divdivonclick"shareTo('qq')"imgsrc"http://zixuephp.net/static/images/qqshare.png"width"32"/divdivonclick"shareTo('sina')"imgsrc"http://zixuephp.net/static/images/sinaweiboshare.png"width"36"/divdivonclick"shareTo('wechat')"imgsrc"http://zixuephp.net/static/images/wechatshare.png"width"32"/divjsfunctionshareTo(stype){varftit'';varflink'';varlk'';//获取文章标题ftit$('.pctitle').text();//获取网页中内容的第一张图片flink$('.pcdetailsimg').eq(0).attr('src');if(typeofflink'undefined'){flink'';}//当内容中没有图片时,设置分享图片为网站logoif(flink''){lk'http://'+window.location.host+'/static/images/logo.png';}//如果是上传的图片则进行绝对路径拼接if(flink.indexOf('/uploads/')!-1){lk'http://'+window.location.host+flink;}//百度编辑器自带图片获取if(flink.indexOf('ueditor')!-1){lkflink;}//qq空间接口的传参if(stype'qzone'){window.open('https://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url'+document.location.href+'?sharesourceqzonetitle'+ftit+'pics'+lk+'summary'+document.querySelector('meta[name"description"]').getAttribute('content'));}//新浪微博接口的传参if(stype'sina'){window.open('http://service.weibo.com/share/share.php?url'+document.location.href+'?sharesourceweibotitle'+ftit+'pic'+lk+'appkey2706825840');}//qq好友接口的传参if(stype'qq'){window.open('http://connect.qq.com/widget/shareqq/index.html?url'+document.location.href+'?sharesourceqzonetitle'+ftit+'pics'+lk+'summary'+document.querySelector('meta[name"description"]').getAttribute('content')+'descphp自学网,一个web开发交流的网站');}//生成二维码给微信扫描分享if(stype'wechat'){window.open('inc/qrcode_img.php?urlhttp://zixuephp.net/article-1.html');}}1.

原作地址:http://www.zixuephp.net/article-309.html

版权声明

即速应用倡导尊重与保护知识产权。如发现本站文章存在版权问题,烦请提供版权疑问、身份证明、版权证明、联系方式等发邮件至197452366@qq.com ,我们将及时处理。本站文章仅作分享交流用途,作者观点不等同于即速应用观点。用户与作者的任何交易与本站无关,请知悉。

产品经理

手机 : 13312967497

擅长 : 小程序流量变现

扫码领取礼包

最新资讯

热门模板

  • 头条
  • 搜狐
  • 微博
  • 百家
  • 一点资讯
  • 知乎