微信分享到朋友圈给分享链接加上图片和文案【源码】
时间:2015-01-04 11:19:07
收藏:0
阅读:2130
参考源码:
1.0假如微信6.02 不能看到分享链接后面的图片的话:
在body里面添加如下代码:(相应的位置改为你需要的)
<img style="width:1px; height:1px;" src="http://web.socialab.com.cn/static/itzu/images/pic300.jpg" alt="" />
var dataForWeixin = {
appId: "",
img: appUrl+"/../static/egg/share.jpg",
url: appUrl+‘?t=0‘,
title: "送你大神手机表客气!“蛋蛋”的喜悦带给你!",
desc: "大神F2全高清手机,要免费拿下不是梦!砸蛋赢大神,敢约吗?!",
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+‘&a=1‘, "desc": dataForWeixin.desc, "title": dataForWeixin.title }, function(e) { switch (e.err_msg) { case "send_app_msg:cancel": case "send_app_msg:fail": case "send_app_msg:confirm": case "send_app_msg:ok": showscore(); } _hmt.push([‘_trackEvent‘, ‘tldeggfriendwx‘, ‘sharepengyou‘, ‘wechat‘, ‘friend‘]) }); }); // 分享到朋友圈; WeixinJSBridge.on(‘menu:share:timeline‘, function(argv){ WeixinJSBridge.invoke(‘shareTimeline‘,{ "img_url":dataForWeixin.img, "img_width":"120", "img_height":"120", "link":dataForWeixin.url+‘&a=2‘, "desc":dataForWeixin.desc, "title":dataForWeixin.desc }, function(e){ switch (e.err_msg) { case "send_app_msg:cancel": case "send_app_msg:fail": case "send_app_msg:confirm": case "send_app_msg:ok": showscore(); } _hmt.push([‘_trackEvent‘, ‘tldeggpyqwx‘, ‘sharepengyou‘, ‘wechat‘, ‘friend‘]) }); }); }; if(document.addEventListener){ document.addEventListener(‘WeixinJSBridgeReady‘, onBridgeReady, false); }else if(document.attachEvent){ document.attachEvent(‘WeixinJSBridgeReady‘ , onBridgeReady); document.attachEvent(‘onWeixinJSBridgeReady‘ , onBridgeReady); } })();
评论(0)