1. 程式人生 > >web網頁外部分享到微信、朋友圈、扣扣、微博等功能、自動生成二維碼等

web網頁外部分享到微信、朋友圈、扣扣、微博等功能、自動生成二維碼等

真的是 nan color 接口 blog har sum height summary

1、這裏重中之重是分享到微信:web端網頁通常是沒有權限分享過去的
所以用: weixin://dl/business/?ticket=ta428dhj739hg3efe6e
但是這個ticket真的是很蛋疼,查了許多資料說還得花錢在第三方對接巴拉巴拉的,
2、所以:window.open(‘http://api.liufuweb.com/api/p5.php?p=d&url=你要分享的鏈接‘);
但是這個缺點是:打開微信的時候要識別二維碼才能訪問到你要分享的頁面
3、就是內嵌入到app端,寫個方法讓其監聽,他們自己調取好了

參考:
https://blog.csdn.net/weiqinhua1/article/details/80514113
http://vip.wxticket.com/api.php

function
shareTo (stype){ var ftit = ‘‘; var flink = ‘‘; var lk = ‘‘; //獲取文章標題 ftit = ‘測試標題‘; //獲取網頁中內容的第一張圖片 flink = ‘/mobile/img/local/invitation.png‘; if(typeof flink == ‘undefined‘){ flink=‘‘; } //當內容中沒有圖片時,設置分享圖片為網站logo if(flink == ‘‘){ lk = ‘http://g.search2.alicdn.com/img/i2/126351555/TB25JDIACtYBeNjSspaXXaOOFXa_!!0-saturn_solar.jpg_220x220.jpg‘; }
//qq空間接口的傳參 if(stype==‘qzone‘){ window.open(‘https://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url=‘+document.location.href+‘?sharesource=qzone&title=‘+ftit+‘&pics=‘+lk+‘&summary=‘+document.querySelector(‘meta[name="description"]‘).getAttribute(‘content‘)); }
//新浪微博接口的傳參 if(stype==‘WB‘){ window.open(‘http://service.weibo.com/share/share.php?url=‘+document.location.href+‘?sharesource=weibo&title=‘+ftit+‘&pic=‘+lk+‘&appkey=2706825840‘); } //分享到微信 if(stype == ‘WX‘){ //window.open(‘weixin://dl/business/?ticket=t2f8d6bf4879b4be12c30ddeea2e265f9‘); window.open(‘http://api.liufuweb.com/api/p5.php?p=d&url=http://192.168.50.13/mobile/finance/be_invited‘); //weixin://dl/business/?ticket=ta428dhj739hg3efe6e -->這個ticket不好實現 } //qq好友接口的傳參 if(stype == ‘QQ‘){ window.open(‘http://connect.qq.com/widget/shareqq/index.html?url=‘+document.location.href+‘?sharesource=qzone&title=‘+ftit+‘&pics=‘+lk+‘&summary="hgjshdhjsdhsgd"‘); } //生成二維碼給微信掃描分享 if(stype == ‘wechat‘){ window.open(‘inc/qrcode_img.php?url=http://zixuephp.net/article-1.html‘); } }

生成二維碼:需要的的js自己動手官網下載好了

 <script src="/mobile/js/finance/jquery.min.js" type="text/javascript"></script>   
<script src="/mobile/js/finance/qrcode.js" type="text/javascript"></script> <div id="qrcode" class="img"></div> var qrcode = new QRCode(document.getElementById("qrcode"), { /* width : 100, height : 100*/ }); var elText = ‘http://192.168.50.13/mobile/finance/be_invited‘; qrcode.makeCode(elText);

web網頁外部分享到微信、朋友圈、扣扣、微博等功能、自動生成二維碼等