对于企业号的开发nodejs 强烈推荐朴大大的
https://github.com/node-webot/wechat-enterprise
List
方法签名 从List对象中根据key取出对应的handler 方法签名 列表中的关键词 静态方法,根据items生成List对象,并放置到缓存中 方法签名 列表名字 元素列表 静态方法,从缓存中根据名字取出List对象 方法签名 列表名字 静态方法,清空缓存的所有的List对象 方法签名 列表名字 Session构造函数,用于与Connect的Session中间件集成的会话脚本 方法签名 Session ID Connect中的请求对象 可选的其余数据,将被合并进Session对象中 保存Session对象到实际的存储中 Callback: 方法签名 保存Session的回调函数 销毁Session对象 Callback: 方法签名 从存储中删除Session数据后的回调函数回复列表类型
函数 List() get
方法 List.prototype.get() 参数 key(String) add
方法 List.add() 参数 name(String) 参数 items(Array) get
方法 List.get() 参数 name(String) clear
方法 List.clear() 参数 name(String) session: API索引
Session
函数 Session() 参数 id(String) 参数 req(Object) 参数 data(Object) save
err
, 错误对象,保存发生错误时传入方法 Session.prototype.save() 参数 callback(Function) destroy
err
, 错误对象,删除发生错误时传入方法 Session.prototype.destroy() 参数 callback(Function) util: API索引
wechat-enterprise: API索引
Handler
微信自动回复平台的内部的Handler对象
方法签名
函数 | Handler() | ||
参数 | config(Object) | 企业号的开发者配置对象 | |
参数 | handle(Function) | handle对象 { token: '', // 公众平台上,开发者设置的Token encodingAESKey: '', // 公众平台上,开发者设置的EncodingAESKey corpId: '', // 企业号的CorpId } |
setHandler
设置handler对象
按消息设置handler对象的快捷方式
text(fn)
image(fn)
voice(fn)
video(fn)
location(fn)
link(fn)
event(fn)
方法签名
方法 | Handler.prototype.setHandler() | ||
参数 | type(String) | handler处理的消息类型 | |
参数 | handle(Function) | handle对象 |
getHandler
根据消息类型取出handler对象
方法签名
方法 | Handler.prototype.getHandler() | ||
参数 | type(String) | 消息类型 |
middlewarify
根据Handler对象生成响应方法,并最终生成中间件函数
方法签名
方法 | Handler.prototype.middlewarify() |
middleware
根据口令
Examples:
使用wechat作为自动回复中间件的三种方式
wechat(config, function (req, res, next) {});wechat(config, wechat.text(function (message, req, res, next) { // TODO}).location(function (message, req, res, next) { // TODO}));wechat(config) .text(function (message, req, res, next) { // TODO }).location(function (message, req, res, next) { // TODO }).middleware();
静态方法
text
,处理文字推送的回调函数,接受参数为(text, req, res, next)。image
,处理图片推送的回调函数,接受参数为(image, req, res, next)。voice
,处理声音推送的回调函数,接受参数为(voice, req, res, next)。video
,处理视频推送的回调函数,接受参数为(video, req, res, next)。location
,处理位置推送的回调函数,接受参数为(location, req, res, next)。link
,处理链接推送的回调函数,接受参数为(link, req, res, next)。event
,处理事件推送的回调函数,接受参数为(event, req, res, next)。
方法签名
函数 | middleware() | ||
参数 | config(Object) | 企业号的开发者配置对象 | |
参数 | handle(Function) | 生成的回调函数,参见示例 |
摘自:http://doxmate.cool/node-webot/wechat-enterprise/api.html
小道消息 近期鹅厂可能有大动作 再企业号上用大招 企业级应用的一个闭环操作 即可展开
更多精彩即将到来
你打算打赏多少钱呢?
(微信扫一扫)