QQ空间、新浪微博、豆瓣等一键分享API链接代码

一、qq空间

&title=默认的文本内容或RICH化转播时的消息体标题,RICH化时最多15个全角字符的长度
&url=转播页的url
&pics=需要转播的图片url,多张以|连接
&summary=分享描述信息
&site=分享来源 如:腾讯网(可选)
&desc=默认分享理由(可选)
&appkey=填写正确的appkey,转播后将显示该key的来源
&line1=消息体第一行的文字,最多15个全角字符的长度
&line2=消息体第二行的文字,最多15个全角字符的长度
&line3=消息体第三行的文字,最多15个全角字符的长度

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

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

二、新浪微博

http://service.weibo.com/share/share.php?url= 

count=表示是否显示当前页面被分享数量(1显示)(可选,允许为空)
&url=将页面地址转成短域名,并显示在内容文字后面。(可选,允许为空)
&appkey=用于发布微博的来源显示,为空则分享的内容来源会显示来自互联网。(可选,允许为空)
&title=分享时所示的文字内容,为空则自动抓取分享页面的title值(可选,允许为空)
&pic=自定义图片地址,作为微博配图(可选,允许为空)
&ralateUid=转发时会@相关的微博账号(可选,允许为空)
&language=语言设置(zh_cn|zh_tw)(可选)

            1.分享到新浪微博接口:http://service.weibo.com/share/share.php?url=你的分享网址&sharesource=weibo&title=你的分享标题&pic=你的分享图片&appkey=你的key

三、豆瓣

https://www.douban.com/share/service?url=

image=分享图片
&url=分享网址
&name=分享标题
&text=分享内容

               1.分享豆瓣:https://www.douban.com/share/service?url=你的分享网址&name=分享标题&text=分享内容

四、生成二维码给微信扫描分享

https://zixuephp.net/inc/qrcode_img.php?url=你的分享网址

五、youku

 https://i.youku.com/

五、代码

    <div>分享到:</div>
    <div onclick="shareTo('qzone')">
        <img src="https://zixuephp.net/static/images/qqzoneshare.png" width="32">
    </div>
    <div onclick="shareTo('qq')">
        <img src="https://zixuephp.net/static/images/qqshare.png" width="32">
    </div>
    <div onclick="shareTo('sina')">
        <img src="https://zixuephp.net/static/images/sinaweiboshare.png" width="32">
    </div>
    <div onclick="shareTo('wechat')">
        <img src="https://zixuephp.net/static/images/wechatshare.png" width="32">
    </div>
    <div onclick="shareTo('tudou')">
       <img src="http://static.youku.com/v1.0.0691/v/img/ico_dou_16x16.png" alt="32">
    </div>
    <!-- youku -->
    <a target="_blank" href="https://i.youku.com/feisu2016?spm=a2hzp.8244740.0.0" class="footer-youku-icon ">
        <img src="https://img-en.fs.com/zh/includes/templates/fiberstore/images/youku.svg" alt="">
    </a>
        function shareTo(types) {
            var title, imageUrl, url, description, keywords;
            //获取文章标题
            title = document.title;

            //获取网页中内容的第一张图片地址作为分享图
            imageUrl = document.images[0].src;
            // imageUrl = document.getElementById("pcdetails").getElementsByTagName("img")[0];
            //当内容中没有图片时,设置分享图片为网站logo
            if (typeof imageUrl == 'undefined') {
                imageUrl = 'https://' + window.location.host + '/static/images/logo.png';
            } else {
                imageUrl = imageUrl.src;
            }

            //获取当前网页url 这个地方根据你的页面来
            // url = document.location.href;
            url = 'feisu.com';

            //获取网页描述
            description = document.querySelector('meta[name="description"]').getAttribute('content');

            //获取网页关键字
            keywords = document.querySelector('meta[name="keywords"]').getAttribute('content');

            //qq空间接口的传参
            if (types == 'qzone') {
                window.open('https://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url=' + url + '&sharesource=qzone&title=' + title + '&pics=' + imageUrl + '&summary=' + description, '', 'width=800,height=650,top=100,left=15');
            }
            //新浪微博接口的传参
            if (types == 'sina') {
                window.open('http://service.weibo.com/share/share.php?url=' + url + '&sharesource=weibo&title=' + title + '&pic=' + imageUrl + '&appkey=2706825840', '', 'width=800,height=650,top=100,left=15,toolbar=no, menubar=no, scrollbars=no, resizable=no');
            }
            //qq好友接口的传参
            if (types == 'qq') {
                window.open('http://connect.qq.com/widget/shareqq/index.html?url=' + url + '&sharesource=qzone&title=' + title + '&pics=' + imageUrl + '&summary=' + description + '&desc=' + keywords, '', 'width=800,height=650,top=100,left=15,toolbar=no, menubar=no, scrollbars=no, resizable=no');
            }
            //生成二维码给微信扫描分享
            if (types == 'wechat') {
                //在线二维码生成只支持小批量调用,过多访问会限制403.
                // https://zixuephp.net/inc/qrcode_img.php接口参数:url:二维码内容,size:二维码图片大小值1-10
                window.open('https://zixuephp.net/inc/qrcode_img.php?url=' + url, '', 'width=800,height=650,top=100,left=15,toolbar=no, menubar=no, scrollbars=no, resizable=no');
            }
            // 豆瓣网
            if (types == 'tudou') {
                //在线二维码生成只支持小批量调用,过多访问会限制403.
                // https://zixuephp.net/inc/qrcode_img.php接口参数:url:二维码内容,size:二维码图片大小值1-10
                window.open('https://www.douban.com/share/service?url=' + url, '', 'width=800,height=650,top=100,left=15,toolbar=no, menubar=no, scrollbars=no, resizable=no');
            }

        }

 

 

 

 

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值