码迷,mamicode.com
首页 > 微信 > 详细

微信网页分享到朋友圈、分享给朋友代码

时间:2014-12-12 14:35:08      阅读:329      评论:0      收藏:0      [点我收藏+]

标签:des   style   blog   http   io   ar   color   sp   on   

  <script>           
           m = window.location.href;
            document.addEventListener(‘WeixinJSBridgeReady‘, function onBridgeReady() {
        window.shareData = {
                "timeLineLink": m,
                "sendFriendLink": m,
                "weiboLink": m,
                "Title": "标题",           //标题
                "Content": "内容",   //内容
                "img_url": "http://s1.hao123img.com/res/images/search_logo/web.png",      //logo地址
                "img_width": "401",
                "img_height": "275",
            };
            // 发送给好友
            WeixinJSBridge.on(‘menu:share:appmessage‘, function (argv) {
                WeixinJSBridge.invoke(‘sendAppMessage‘, {
                    "img_url": window.shareData.img_url,
                    "img_width": window.shareData.img_width,
                    "img_height": window.shareData.img_height,
                    "link": window.shareData.sendFriendLink,
                    "desc": window.shareData.Content,
                    "title": window.shareData.Title
                }, function (res) {
                    _report(‘send_msg‘, res.err_msg);
                })
            });
            // 分享到朋友圈
            WeixinJSBridge.on(‘menu:share:timeline‘, function (argv) {
                WeixinJSBridge.invoke(‘shareTimeline‘, {
                    "img_url": window.shareData.img_url,
                    "img_width": window.shareData.img_width,
                    "img_height": window.shareData.img_height,
                    "link": window.shareData.timeLineLink,
                    "desc": window.shareData.Content,
                    "title": window.shareData.Title
                }, function (res) {
                    _report(‘timeline‘, res.err_msg);
                });
            });

        }, false)
    </script>

 

微信网页分享到朋友圈、分享给朋友代码

标签:des   style   blog   http   io   ar   color   sp   on   

原文地址:http://www.cnblogs.com/yutaoyao/p/4159545.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!