PHP+微信分享自定义小图标
微信分享以后的小图标如下图:
<script>
document.addEventListener(‘WeixinJSBridgeReady‘, function onBridgeReady() {
window.shareData = {
"imgUrl": "<?php if(stripos(‘y‘.$detail[‘start_picurl‘], ‘http://‘)!=1){echo $Think.config.HTTP_STCDOMIN;}echo $detail[‘start_picurl‘];?>",
"timeLineLink": "{$Think.config.HTTP_DOMIN}?g=app&m=fruit&id={$Think.get.id}&wid={$Think.get.wid}&user=",
"sendFriendLink": "{$Think.config.HTTP_DOMIN}?g=app&m=fruit&id={$Think.get.id}&wid={$Think.get.wid}&user=",
"weiboLink": "{$Think.config.HTTP_DOMIN}g=app&m=fruit&id={$Think.get.id}&wid={$Think.get.wid}&user=",
"tTitle": "{$detail.a_name}",
"tContent": "亲,请点击进入摇摇乐页面,快来参加活动吧!~",
"fTitle": "{$detail.a_name}",
"fContent": "亲,请点击进入摇摇乐页面,快来参加活动吧!~",
"wContent": "亲,请点击进入摇摇乐页面,快来参加活动吧!~"
};
// 发送给好友
WeixinJSBridge.on(‘menu:share:appmessage‘, function (argv) {
WeixinJSBridge.invoke(‘sendAppMessage‘, {
"img_url": window.shareData.imgUrl,
"img_width": "640",
"img_height": "640",
"link": window.shareData.sendFriendLink,
"desc": window.shareData.fContent,
"title": window.shareData.fTitle
}, function (res) {
_report(‘send_msg‘, res.err_msg);
})
});
// 分享到朋友圈
WeixinJSBridge.on(‘menu:share:timeline‘, function (argv) {
WeixinJSBridge.invoke(‘shareTimeline‘, {
"img_url": window.shareData.imgUrl,
"img_width": "640",
"img_height": "640",
"link": window.shareData.timeLineLink,
"desc": window.shareData.tContent,
"title": window.shareData.tTitle
}, function (res) {
_report(‘timeline‘, res.err_msg);
});
});
// 分享到微博
WeixinJSBridge.on(‘menu:share:weibo‘, function (argv) {
WeixinJSBridge.invoke(‘shareWeibo‘, {
"content": window.shareData.wContent,
"url": window.shareData.weiboLink,
}, function (res) {
_report(‘weibo‘, res.err_msg);
});
});
}, false)
</script>