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

webview中定制微信分享

时间:2014-12-04 12:25:19      阅读:561      评论:0      收藏:0      [点我收藏+]

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

 微信webview中分享默认抓取网页title,网页上第一张大图,当前网页链接作为分享素材(同易信),但是通过JsBridge可以用js定制分享的素材,此api并没有公开在官方文档中,记录如下:
     document.addEventListener(‘WeixinJSBridgeReady‘, function onBridgeReady() {
                /** 发送给好友 **/
                WeixinJSBridge.on(‘menu:share:appmessage‘, function(argv){
                     WeixinJSBridge.invoke(_eventName,{
                                    "appid": ‘xxx‘,
                                    "img_url": "xxxx",
                                    "img_width": "320",
                                    "img_height": "320",
                                    "link": ‘http://xxxx’,
                                    "desc": “朋友圈中别忘了填",
                                    "title": “xxxx"
                                    }, function(res) {
                                        // 我是回调,很精彩,有ready,有执行,有后事
                                    });
                    });
                
                /** 分享到朋友圈 **/
                WeixinJSBridge.on(‘menu:share:timeline‘, function(argv){
                    WeixinJSBridge.invoke(_eventName,{
                                    "appid": ‘xxx‘,
                                    "img_url": "xxxx",
                                    "img_width": "320",
                                    "img_height": "320",
                                    "link": ‘http://xxxx’,
                                    "desc": “朋友圈中别忘了填",
                                    "title": “xxxx"
                                    }, function(res) {
                                    });
                    });
                    
                 /** 分享到微博 **/
                WeixinJSBridge.on(‘menu:share:weibo‘, function(argv){
                     WeixinJSBridge.invoke(‘shareWeibo‘,{
                                    "content": "xxxx",
                                    "url": ‘http://xxxx‘,                                    }, function(res) {
                                    });
                });
        }, false); 

另外还有些有用的api,有人总结了,可以参见https://github.com/zxlie/WeixinApi   

webview中定制微信分享

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

原文地址:http://my.oschina.net/u/157566/blog/352146

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