微信公众号开发 常用脚本累计

关注指定公众号:

//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){ //转发成功 }; });

 

微信公众号开发 常用脚本累计

相关文章