javascript实现微信分享


代码很简单,我这里就不多废话了,直接奉上源码:

http://tkfeng.hk.myjsp.wang/jianwuye/img/avatar1.jpg";
         var lineLink = "http://tkfeng.hk.myjsp.wang/jianwuye/login.html";
         var descContent = '测试别当真';
         var shareTitle = '分享';
        var appid = 'wx1259b351c201841d';
        function shareFriend() {
            WeixinJSBridge.invoke('sendAppMessage',{
                "appid": appid,
                "img_url": imgUrl,
                "img_width": "200",
                "img_height": "200",
                "link": lineLink,
                "desc": descContent,
                "title": shareTitle
            }, function(res) {
                //_report('send_msg', res.err_msg);
            });
        }
        function shareTimeline() {
            WeixinJSBridge.invoke('shareTimeline',{
                "img_url": imgUrl,
                "img_width": "200",
                "img_height": "200",
                "link": lineLink,
                "desc": descContent,
                "title": shareTitle
            }, function(res) {
                   //_report('timeline', res.err_msg);
            });
        }
        function shareWeibo() {
            WeixinJSBridge.invoke('shareWeibo',{
                "content": descContent,
                "url": lineLink,
            }, function(res) {
                //_report('weibo', res.err_msg);
            });
        }
        // 当微信内置浏览器完成内部初始化后会触发WeixinJSBridgeReady事件。
        document.addEventListener('WeixinJSBridgeReady', function onBridgeReady() {
            // 发送给好友
            WeixinJSBridge.on('menu:share:appmessage', function(argv){
                shareFriend();
            });
            // 分享到朋友圈
            WeixinJSBridge.on('menu:share:timeline', function(argv){
                shareTimeline();
            });
            // 分享到微博
            WeixinJSBridge.on('menu:share:weibo', function(argv){
                shareWeibo();
            });
        }, false);
        </script> -->
            <h1>呵呵呵呵</h1>          
  </body>
</html>

是不是很好用呢小伙伴们。大家美化下用到自己的项目中去吧



相关阅读:
C语言关系运算符实例详解
php json与xml序列化/反序列化
java基础学习笔记之反射
PHP Ajax JavaScript Json获取天气信息实现代码
win8怎关闭平滑过度的窗口提升畅快体验?
浅谈被jQuery抛弃的函数及替代函数
PHP实现数字补零功能的2个函数介绍
Swift图像处理之优化照片
Win7安装之后需要做哪些清理工作从哪开始
简明CSS定位属性position
Android开发之Sqliteopenhelper用法实例分析
java读取properties文件的方法实例分析
Android编程之绝对布局AbsoluteLayout和相对布局RelativeLayout实例详解
Jquery中Event对象属性小结
快速导航

Copyright © 2016 phpStudy |