微信取消了微信公众平台前端网页上添加分享到朋友圈,关注微信等按钮,目前我们所能做的唯一定制化就是自定义微信发送给好友,分享到朋友圈的缩略图,链接,标题和摘要。今天刚好遇到分享下代码:
<script type="text/javascript"> var dataForWeixin={ appId:"", MsgImg:"$dataForWeixin[‘MsgImg‘]", TLImg:"$dataForWeixin[‘MsgImg‘]", url: ‘{$share_url}‘, title:"$dataForWeixin[‘title‘]", desc:"$dataForWeixin[‘desc‘]", fakeid:"", }; (function(){ var onBridgeReady=function(){ // 发送给好友; WeixinJSBridge.on(‘menu:share:appmessage‘, function(argv){ WeixinJSBridge.invoke(‘sendAppMessage‘,{ "appid": dataForWeixin.appId, "img_url": dataForWeixin.img, "img_width": "120", "img_height": "120", "link": dataForWeixin.url, "desc": dataForWeixin.desc, "title": dataForWeixin.title }, function(res){(dataForWeixin.callback)(res);}); // 分享到朋友圈; WeixinJSBridge.on(‘menu:share:timeline‘, function(argv){ WeixinJSBridge.invoke(‘shareTimeline‘,{ "img_url":dataForWeixin.img, "img_width":"120", "img_height":"120", "link":dataForWeixin.url, "desc":dataForWeixin.desc, "title":dataForWeixin.title }, function(res)(res){(dataForWeixin.callback)(res);}); }); // 分享到微博; WeixinJSBridge.on(‘menu:share:weibo‘, function(argv){ WeixinJSBridge.invoke(‘shareWeibo‘,{ "content":dataForWeixin.title+‘ ‘+dataForWeixin.url, "url":dataForWeixin.url }, function(res){(dataForWeixin.callback)(res);}); }); // 分享到Facebook WeixinJSBridge.on(‘menu:share:facebook‘, function(argv){ WeixinJSBridge.invoke(‘shareFB‘,{ "img_url":dataForWeixin.img, "img_width":"120", "img_height":"120", "link":dataForWeixin.url, "desc":dataForWeixin.desc, "title":dataForWeixin.title }, function(res){(dataForWeixin.callback)(res);}); }); }; if(document.addEventListener){ document.addEventListener(‘WeixinJSBridgeReady‘, onBridgeReady, false); }else if(document.attachEvent){ document.attachEvent(‘WeixinJSBridgeReady‘ , onBridgeReady); document.attachEvent(‘onWeixinJSBridgeReady‘ , onBridgeReady); } })(); </script>
GetwxLink
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。