博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
微信公众号开发 常用脚本累计
阅读量:7172 次
发布时间:2019-06-29

本文共 3904 字,大约阅读时间需要 13 分钟。

 

 

关注指定公众号:

//gh_ef65912f88f1 为被添加者的微信IDWeixinJSBridge.invoke("addContact", {webtype: "1",username: 'gh_ef65912f88f1'}, function(e) {            WeixinJSBridge.log(e.err_msg);            //e.err_msg:add_contact:added 已经添加            //e.err_msg:add_contact:cancel 取消添加            //e.err_msg:add_contact:ok 添加成功            if(e.err_msg == 'add_contact:added' || e.err_msg == 'add_contact:ok'){                //关注成功,或者已经关注过            }        })

 分享到朋友圈:

WeixinJSBridge.invoke('shareTimeline',{        "img_url": "http://example.com/example.png",        //"img_width": "640",        //"img_height": "640",        "link": "http://example.com",        "desc": "描述",        "title": "标题"    },function(res){        // 返回res.err_msg,取值        // share_timeline:cancel 用户取消        // share_timeline:fail 发送失败        // share_timeline:confirm 发送成功        WeixinJSBridge.log(res.err_msg);                 if(res.err_msg == 'share_timeline:confirm'){            //转发成功        };    });

 

function weixinShareTimeline(title,desc,link,imgUrl){WeixinJSBridge.invoke(‘shareTimeline’,{“img_url”:imgUrl,//”img_width”:”640″,//”img_height”:”640″,“link”:link,“desc”: desc,“title”:title});}

发送给好友:

function weixinSendAppMessage(title,desc,link,imgUrl){WeixinJSBridge.invoke(‘sendAppMessage’,{//”appid”:appId,“img_url”:imgUrl,//”img_width”:”640″,//”img_height”:”640″,“link”:link,“desc”:desc,“title”:title});}

分享到腾讯微博:

function weixinShareWeibo(title,link){WeixinJSBridge.invoke(‘shareWeibo’,{“content”:title + link,“url”:link});}

关注指定的微信号:

function weixinAddContact(name){WeixinJSBridge.invoke(“addContact”, {webtype: “1″,username: name},function(e) {WeixinJSBridge.log(e.err_msg);//e.err_msg:add_contact:added 已经添加//e.err_msg:add_contact:cancel 取消添加//e.err_msg:add_contact:ok 添加成功if(e.err_msg== ‘add_contact:added’ || e.err_msg ==‘add_contact:ok’){//关注成功,或者已经关注过}})}

 

var imgUrl = 'http://su.bdimg.com/static/superplus/img/logo_white.png';//这里是分享的时候的那个图片var lineLink = 'http://baidu.com';//这个是分享的网址var descContent = "这个操作的介绍,没发现他有啥用";var shareTitle = '这是题目题目题目';var appid = 'wxc9937e3a66af6dc8';  //这里写开发者接口里的appidfunction shareFriend() {    WeixinJSBridge.invoke('sendAppMessage',{                            "appid": appid,                            "img_url": imgUrl,                            "img_width": "640",                            "img_height": "640",                            "link": lineLink,                            "desc": descContent,                            "title": shareTitle                            }, function(res) {                            _report('send_msg', res.err_msg);                            })}function shareTimeline() {    WeixinJSBridge.invoke('shareTimeline',{                            "img_url": imgUrl,                            "img_width": "640",                            "img_height": "640",                            "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);

 

转载地址:http://pvbzm.baihongyu.com/

你可能感兴趣的文章
用mysql查询某字段是否有索引
查看>>
ubuntu 查看进程,查看服务
查看>>
Cisco DHCP Snooping + IPSG 功能实现
查看>>
Linux命令_用户身份切换
查看>>
学习在.NET Core中使用RabbitMQ之启动和基础(一)
查看>>
支付业务的数据库表的设计
查看>>
php面试题二--解决网站大流量高并发方案(从url到硬盘来解决高并发方案总结)...
查看>>
PHP 16 个编程法则
查看>>
【微信】2.微信小程序开发--官方开发工具使用说明
查看>>
RedisTemplate访问Redis数据结构
查看>>
面试如何回答优化数据库
查看>>
SuperSocket与Netty之实现protobuf协议,包括服务端和客户端
查看>>
ASP.NET CORE系列【二】使用Entity Framework Core进行增删改查
查看>>
js如何返回两个数的商的整数和余数部分?
查看>>
AIDL基本使用
查看>>
MySQL中间件之ProxySQL(6):管理后端节点
查看>>
Mathematica 取整函数
查看>>
使用Java进行串口SerialPort通讯
查看>>
(转)Awsome Domain-Adaptation
查看>>
利用cwRsync客户端将Windows下文件同步到Linux
查看>>