{"id":21046910,"url":"https://github.com/eryouhao/node-work-wechat","last_synced_at":"2025-05-15T19:31:24.002Z","repository":{"id":57156709,"uuid":"85387592","full_name":"EryouHao/node-work-wechat","owner":"EryouHao","description":"基于Node.js的企业微信消息接口服务中间件","archived":false,"fork":false,"pushed_at":"2019-04-11T10:17:04.000Z","size":6,"stargazers_count":17,"open_issues_count":2,"forks_count":6,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-25T05:07:15.587Z","etag":null,"topics":["node-work-wechat","nodejs","work-wechat"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/EryouHao.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-03-18T08:44:31.000Z","updated_at":"2023-07-02T04:25:16.000Z","dependencies_parsed_at":"2022-08-30T03:20:50.969Z","dependency_job_id":null,"html_url":"https://github.com/EryouHao/node-work-wechat","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EryouHao%2Fnode-work-wechat","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EryouHao%2Fnode-work-wechat/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EryouHao%2Fnode-work-wechat/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EryouHao%2Fnode-work-wechat/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/EryouHao","download_url":"https://codeload.github.com/EryouHao/node-work-wechat/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254407298,"owners_count":22066212,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["node-work-wechat","nodejs","work-wechat"],"created_at":"2024-11-19T14:34:23.136Z","updated_at":"2025-05-15T19:31:23.772Z","avatar_url":"https://github.com/EryouHao.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# node-work-wechat\n\n基于Node.js的企业微信消息接口服务中间件\n\n已实现：\n- 消息服务器的认证\n- 获取access_token\n- 被动回复消息(机器人)\n- 主动推送消息\n\n# Installation\n``` shell\n$ npm install node-work-wechat\n```\n# Use with Express\n``` javascript\nvar WorkWechat = require('node-work-wechat');\n\nvar config = {\n  token: 'xxxxxx', // 随机数，用于消息服务器验证\n  encodingAESKey: 'xxxxxx', // 消息加密密钥\n  corpid: 'xxxxxx', // 公司ID\n  secret: 'xxxxxx', // 应用密钥\n  agentid: xxxxx, // 应用ID\n  touser: 'UserID1|UserID2|UserID3', // userID\n};\n\n// init\nvar wxcpt = new WorkWechat(config);\n\n// 接收消息服务器配置\napp.get('/work-wechat', function (req, res, next) {\n  wxcpt.connectServer(req, res);\n});\n\n// 被动回复消息\napp.post('/work-wechat', function (req, res, next) {\n  wxcpt.reply(res, {\n    type: 'text',\n    content: 'hello!'\n  });\n});\n\n// 获取access_token\nwxcpt.updateToken();\n\n// 主动推送消息\nwxcpt.sendMsg('hello!');\n```\n\n若想拿到用户发往应用消息，需引入\n``` shell\n$ npm install body-parser body-parser-xml\n```\n``` javascript\nvar bodyParser = require('body-parser');\nrequire('body-parser-xml')(bodyParser);\n\n...\napp.post('/work-wechat', function (req, res, next) {\n  console.log(wxcpt.getMsg(req)); // eg. send hello , return hello\n});\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feryouhao%2Fnode-work-wechat","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feryouhao%2Fnode-work-wechat","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feryouhao%2Fnode-work-wechat/lists"}