微信公众平台开发最佳实践
    
    
        
            document.addEventListener('WeixinJSBridgeReady', function onBridgeReady() {
                // 发送给好友
                WeixinJSBridge.on('menu:share:appmessage', function (argv) {
                    WeixinJSBridge.invoke('sendAppMessage', {
                        "appid": "123",
                        "img_url": "http://bcs.duapp.com/api100/p_w_picpath/logo/lover.jpg",
                        "img_width": "160",
                        "img_height": "160",
                        "link": "http://api100.duapp.com/card/",
                        "desc":  "山无陵,天地合,乃敢与君绝。",
                        "title": "爱情贺卡"
                    }, function (res) {
                        _report('send_msg', res.err_msg);
                    })
                });

                // 分享到朋友圈
                WeixinJSBridge.on('menu:share:timeline', function (argv) {
                    WeixinJSBridge.invoke('shareTimeline', {
                        "img_url": "http://bcs.duapp.com/api100/p_w_picpath/logo/newyear.jpg",
                        "img_width": "160",
                        "img_height": "160",
                        "link": "http://api100.duapp.com/card/",
                        "desc":  "Best wishes for a wonderful new year.",
                        "title": "新年贺卡"
                    }, function (res) {
                        _report('timeline', res.err_msg);
                    });
                });
            }, false)