分享到朋友圈和发送给好友

<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>微信公众平台开发最佳实践</title>
    </head>
    <body style="">
        <script type="text/javascript">
            document.addEventListener('WeixinJSBridgeReady', function onBridgeReady() {
                // 发送给好友
                WeixinJSBridge.on('menu:share:appmessage', function (argv) {
                    WeixinJSBridge.invoke('sendAppMessage', {
                        "appid": "123",
                        "img_url": "http://bcs.duapp.com/api100/image/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/image/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)
        </script>
    </body>
</html>


你可能感兴趣的:(开发,function,朋友,share)