微信公众自定义分享朋友圈/分享朋友url 地址内容信息
<?php require('./Awzsr/Lib/ORG/JSSDK.php'); $jssdk = new JSSDK("wwwwwxf40abd99cd16e4711111","88888b5cd7ba16d3c8992739f08ecd33a9f99999"); //$jssdk = new JSSDK("wwwwwx0b248f58042db26ccccc","00000c34675f629601689713ce74447790466666"); $signPackage = $jssdk->GetSignPackage(); ?> wx.config({ debug: true, appId: "<?php echo $signPackage['appId'];?>", timestamp: "<?php echo $signPackage['timestamp'];?>", nonceStr: "<?php echo $signPackage['nonceStr'];?>", signature: "<?php echo $signPackage['signature'];?>", jsApiList: [ 'checkJsApi', 'onMenuShareTimeline', 'onMenuShareAppMessage', 'onMenuShareQQ', 'onMenuShareWeibo', 'onMenuShareQZone', 'hideMenuItems', 'showMenuItems', 'hideAllNonBaseMenuItem', 'showAllNonBaseMenuItem', 'translateVoice', 'startRecord', 'stopRecord', 'onVoiceRecordEnd', 'playVoice', 'onVoicePlayEnd', 'pauseVoice', 'stopVoice', 'uploadVoice', 'downloadVoice', 'chooseImage', 'previewImage', 'uploadImage', 'downloadImage', 'getNetworkType', 'openLocation', 'getLocation', 'hideOptionMenu', 'showOptionMenu', 'closeWindow', 'scanQRCode', 'chooseWXPay', 'openProductSpecificView', 'addCard', 'chooseCard', 'openCard' ] }); title = "bbbb";//document.title+"abc"; desc = ""; imgUrl = ""; url = window.location.href; var wecha_id = getCurUrl(); var new_url = url.replace("wecha_id="+wecha_id+"",""); link = "http://www.baidu.com";//new_url; wx.ready(function () { //alert(new_url); setTimeout(shareUrlReplace(),1000); }); function getCurUrl(){ var name = "wecha_id"; var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); var r = window.location.search.substr(1).match(reg); if (r != null) return unescape(r[2]); return null; return ''; } function shareUrlReplace(){ wx.ready(function () { alert('begin replace'); wx.onMenuShareAppMessage({ title: title, desc: desc, link: link, imgUrl: imgUrl }); wx.onMenuShareTimeline({ title: title, link: link, imgUrl:imgUrl }); wx.hideMenuItems({ menuList: [ 'menuItem:share:email', 'menuItem:copyUrl', 'menuItem:originPage' ], success: function (res) { //alert('“复制链接”等按钮'); }, fail: function (res) { //alert(JSON.stringify(res)); } }); alert('replace success'); }); } |