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

微信分享,使用js,分享给朋友,朋友圈,QQ微博

时间:2014-11-07 22:02:36      阅读:325      评论:0      收藏:0      [点我收藏+]

标签:des   style   blog   http   io   color   ar   使用   sp   

 1 <script>
 2     var imgUrl = "http://www.baidu.com/img/bdlogo.gif";
 3     var lineLink = "http://www.baidu.com";
 4     var descContent = ‘亲子游来玩了‘;
 5     var shareTitle = ‘我的标题‘;
 6     var appid = ‘‘;
 7     function shareFriend() {
 8         WeixinJSBridge.invoke(‘sendAppMessage‘,{
 9             "appid": appid,
10             "img_url": imgUrl,
11             "img_width": "200",
12             "img_height": "200",
13             "link": lineLink,
14             "desc": descContent,
15             "title": shareTitle
16         }, function(res) {
17     
18         });
19     }
20     
21     function shareTimeline() {
22         WeixinJSBridge.invoke(‘shareTimeline‘,{
23             "img_url": imgUrl,
24             "img_width": "200",
25             "img_height": "200",
26             "link": lineLink,
27             "desc": descContent,
28             "title": shareTitle
29         }, function(res) {
30             
31         });
32     }
33     
34     function shareWeibo() {
35         WeixinJSBridge.invoke(‘shareWeibo‘,{
36             "content": descContent,
37             "url": lineLink,
38         }, function(res) {
39     
40         });
41     }
42     
43     // 当微信内置浏览器完成内部初始化后会触发WeixinJSBridgeReady事件。
44     document.addEventListener(‘WeixinJSBridgeReady‘, function onBridgeReady() {
45         // 发送给好友
46         WeixinJSBridge.on(‘menu:share:appmessage‘, function(argv){
47             shareFriend();
48         });
49         // 分享到朋友圈
50         WeixinJSBridge.on(‘menu:share:timeline‘, function(argv){
51             shareTimeline();
52         });
53         // 分享到微博
54         WeixinJSBridge.on(‘menu:share:weibo‘, function(argv){
55             shareWeibo();
56         });
57     }, false);
58 </script>

 

微信分享,使用js,分享给朋友,朋友圈,QQ微博

标签:des   style   blog   http   io   color   ar   使用   sp   

原文地址:http://www.cnblogs.com/h07061108/p/wechat_share.html

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