{"id":19035498,"url":"https://github.com/node-webot/co-wechat-enterprise-api","last_synced_at":"2025-07-09T09:12:04.455Z","repository":{"id":150137632,"uuid":"38996848","full_name":"node-webot/co-wechat-enterprise-api","owner":"node-webot","description":null,"archived":false,"fork":false,"pushed_at":"2016-03-19T09:36:15.000Z","size":35,"stargazers_count":7,"open_issues_count":1,"forks_count":11,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-18T04:12:45.992Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/node-webot.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"MIT-License","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-07-13T07:10:20.000Z","updated_at":"2020-07-10T07:33:14.000Z","dependencies_parsed_at":"2023-04-26T00:32:20.086Z","dependency_job_id":null,"html_url":"https://github.com/node-webot/co-wechat-enterprise-api","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/node-webot%2Fco-wechat-enterprise-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/node-webot%2Fco-wechat-enterprise-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/node-webot%2Fco-wechat-enterprise-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/node-webot%2Fco-wechat-enterprise-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/node-webot","download_url":"https://codeload.github.com/node-webot/co-wechat-enterprise-api/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250488135,"owners_count":21438724,"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":[],"created_at":"2024-11-08T21:51:00.476Z","updated_at":"2025-04-23T18:23:03.701Z","avatar_url":"https://github.com/node-webot.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"Wechat Enterprise API(ES6版)\n============================\n微信企业号API。\n\n## 模块状态\n- [![NPM version](https://badge.fury.io/js/co-wechat-enterprise-api.png)](http://badge.fury.io/js/co-wechat-enterprise-api)\n- [![Build Status](https://travis-ci.org/node-webot/co-wechat-enterprise-api.png?branch=master)](https://travis-ci.org/node-webot/co-wechat-enterprise-api)\n- [![Dependencies Status](https://david-dm.org/node-webot/co-wechat-enterprise-api.png)](https://david-dm.org/node-webot/co-wechat-enterprise-api)\n- [![Coverage Status](https://coveralls.io/repos/node-webot/co-wechat-enterprise-api/badge.png)](https://coveralls.io/r/node-webot/co-wechat-enterprise-api)\n\n## 功能列表\n- 主动消息\n- 菜单操作\n- 部门管理\n- 用户管理\n- 标签管理\n- 媒体文件\n- OAuth API（授权、获取基本信息）\n- JS SDK 授权\n- 管理企业号应用\n- 通讯录批量操作接口\n- 永久素材管理接口\n- 企业号摇一摇周边接口\n\n\n详细参见[API文档](http://doxmate.cool/node-webot/co-wechat-enterprise-api/api.html)\n\n微信企业号官方文档(http://qydev.weixin.qq.com/wiki/index.php)\n\n订阅号和服务号版本请前往：\u003chttps://github.com/node-webot/co-wechat-api\u003e\n\n## Installation\n\n```sh\n$ npm install co-wechat-enterprise-api\n```\n\n## Usage\n\n```js\nvar API = require('co-wechat-enterprise-api');\n\nvar api = new API(corpid, corpsecret);\nvar result = yield* api.updateRemark('open_id', 'remarked');\n```\n\n### 多进程\n当多进程时，token需要全局维护，以下为保存token的接口。\n```\nvar api = new API('corpid', 'corpsecret', function* () {\n  // 传入一个获取全局token的方法\n  var txt = yield fs.readFile('access_token.txt', 'utf8');\n  return JSON.parse(txt);\n}, function* (token) {\n  // 请将token存储到全局，跨进程、跨机器级别的全局，比如写到数据库、redis等\n  // 这样才能在cluster模式及多机情况下使用，以下为写入到文件的示例\n  yield fs.writeFile('access_token.txt', JSON.stringify(token));\n});\n```\n\n## 内网节点如何通过代理访问\n### 通过代理服务器访问\n\n#### 场景\n\n对于大规模的集群部署模式，为了安全和速度，会有一些负载均衡的节点放在内网的服务器上（即负载均衡的节点与主结点通过内网连接，并且内网服务器上没有外网的IP）。这时，就需要配置代理服务器来使内网的机器可以有限度的访问外网的资源。例如：微信套件中的各种主动调用接口。\n\n如何架设代理服务器在这里不做赘述，一般推荐使用squid 3，免费、快速、配置简单。\n\n#### 技术原理\n\n由于需要访问的微信API服务器是https协议，所以普通的http代理模式不能使用。\n而一般都是http协议的代理服务器。\n我们要实现的就是通过http代理通道来走https的请求。\n\n基本的步骤是2步：\n\n- 连接到代理服务器，发送CONNECT命令，打开一个TCP连接。\n- 使用上一步打开的TCP连接，发送https的请求。\n\n#### 实现步骤\n\n一、下载[node-tunnel](https://github.com/koichik/node-tunnel) 注意：npm上的版本较老，不支持node v0.10以上的版本。\n\n二、使用 httpsOverHttp 这个agent。\n\n三、将agent配置给httpx。\n\n```js\nvar tunnel = require('tunnel');\n\nvar agent = tunnel.httpsOverHttp({\n  proxy: {\n    host: 'proxy_host_ip', // 代理服务器的IP\n    port: 3128 // 代理服务器的端口\n  }\n});\n\napi.setOpts({\n   agent: agent\n});\n\n```\n\n## License\nThe MIT license.\n\n## 交流群\nQQ群：157964097，使用疑问，开发，贡献代码请加群。\n\n## 感谢\n感谢以下贡献者：\n\n```\n\n project  : co-wechat-api\n repo age : 1 year, 1 month\n active   : 14 days\n commits  : 44\n files    : 70\n authors  :\n    32  Jackson Tian  72.7%\n     6  magicxie      13.6%\n     2  TimZhang      4.5%\n     2  ken           4.5%\n     2  马剑          4.5%\n\n```\n\n## 捐赠\n如果您觉得Wechat对您有帮助，欢迎请作者一杯咖啡\n\n![捐赠wechat](https://cloud.githubusercontent.com/assets/327019/2941591/2b9e5e58-d9a7-11e3-9e80-c25aba0a48a1.png)\n\n或者[![](http://img.shields.io/gratipay/JacksonTian.svg)](https://www.gittip.com/JacksonTian/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnode-webot%2Fco-wechat-enterprise-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnode-webot%2Fco-wechat-enterprise-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnode-webot%2Fco-wechat-enterprise-api/lists"}